Grouping on more than one level

You can group by more than one field. For example, using the Employee table:

SELECT Department, Age, COUNT(*) FROM Employee GROUP BY Department, Age;

produces the following table:

Department

Age

COUNT(*)

ADMIN

30

1

SALES

25

2

TECH

24

1

TECH

43

1

See also:

Groups and aggregate functions

Finding duplicate records

Other types of SQL statements