次のSELECT文では、employeeテーブルのすべての従業員のうち、給与が平均よりも高い従業員を抽出します。
SELECT name, dept_no, jobtitle, salary FROM employee WHERE salary > (SELECT AVG(salary) FROM employee) ORDER BY name;
文は、この結果テーブルを返します。
name ---- |
dept_no ------- |
jobtitle -------- |
salary ------ |
---|---|---|---|
Aguilar J | 600 | manager | 45,000.00 |
Carter J | 500 | Engineer | 44,000.00 |
Omura H | 500 | Programmer | 40,000.00 |
Phan A | 300 | Vice President | 55,000.00 |
Regan R | 600 | Purchaser | 44,000.00 |
Russell S | 300 | President | 65,000.00 |
Smith T | 500 | Engineer | 42,000.00 |
Smith T | 700 | manager | 45,000.00 |
Watson L | 500 | Vice President | 56,000.00 |