|
1. Find the salaries for the employees in the "Research" department: SELECT salary FROM employee, department WHERE dno = dnumber AND dname = 'Research' |
|
This query finds the average salary paid to employees in the whole company: SELECT AVG(salary) FROM employee |
Simplification ---- because:
SELECT AVG(salary) FROM employee |
returns one single value, we can omit the ALL keyword:
SELECT fname, lname
FROM employee
WHERE dno IN ( SELECT dnumber
FROM department
WHERE dname = 'Research' )
AND
salary >
|
|
The following query finds the average salary paid to employees in the 'Research' department: SELECT AVG(salary) FROM employee, department WHERE dno = dnumber AND dname = 'Research' |
Reason: :
|
SELECT fname, lname FROM employee WHERE dno IN ( SELECT dnumber /* Emp in the Research dept */ FROM department WHERE dname = 'Research' ) AND salary > (SELECT AVG(salary) FROM employee, department WHERE dno = dnumber AND dname = 'Research') |