How to use Group By clause in a query

Example

Employees table

IDMANAGER_IDSALDEPT_ID
183000I
283000I
31800I
47950I
521100I
691300I
7102850I
8102975I
9102450I
10NULL5000I

Count the number of employees group by department

SELECT COUNT(ID) EMP_NO, DEPT_ID
FROM EMPLOYEES
WHERE MANAGER_ID IS NOT NULL
GROUP BY DEPT_ID;

Results

EMP_NODEPT_ID
210
520
230

Select the sum of salary group by department

SELECT DEPT_ID, SUM(SAL) SAL_SUM
FROM EMPLOYEES
GROUP BY DEPT_ID;

Results

DEPT_IDSAL_SUM
108750.00
2010875.00
303800.00