To share the array into groups of rows using the GROUP BY clause.
A single group of all the rows for which the values in the GROUP BY clause are identical.
To calculate the average salary in each department, we write:
SELECT DEPTNO, AVG (SAL) FROM EMP
GROUP BY DEPTNO;
Before grouping, we can eliminate some rows using the WHERE clause:
JOB SELECT MAX (SAL)
FROM EMP
WHERE JOB <> 'CLERK'
GROUP BY JOB;
The GROUP BY clause, you can give some expression, then the rows are grouped together in smaller groups.
To calculate the minimum salary in each department in the division for the posts we write:
SELECT DEPTNO, JOB, MIN (SAL) FROM EMP GROUP BY DEPTNO, JOB;
No comments:
Post a Comment