To calculate the average earnings in the company, we write:
SELECT AVG (SAL) FROM EMP;
Note that one value is returned for all rows. The entire company is treated as one group.
You can apply it to the condition in the WHERE clause, for example, to find the minimum wage as a 'manager', we write:
SELECT MIN (SAL)
FROM EMP
WHERE JOB = 'MANAGER';
To find how many employees work in the department of 10, we write:
SELECT COUNT (*) FROM EMP WHERE DEPTNO = 10;
No comments:
Post a Comment