Notes_on_group_by
Notes_on_group_by
DML
TCL
DQL
SELECT
WHERE
AND
OR
NOT
LIKE
BETWEEN
IN
DESC
COUNT
DISTINCT
ORDER BY
IS NULL
IS NOT NULL
MAX()
MIN()
SUM()
AVG()
COUNT()
Group functions will work on set of the records. they will not work on single
record.
Rule : The columns which are out of the group functions in the select statement ,
must be present in group by clause.
Eg:
SELECT DEPARTMENT_ID , JOB_ID , MANAGER_ID , MAX(SALARY)
FROM EMPLOYEES
GROUP BY DEPARTMENT_ID , JOB_ID , MANAGER_ID
ORDER BY DEPARTMENT_ID , JOB_ID , MANAGER_ID;