6. Summarising and Grouping: Step 2

Demo

Average, min and max.

To get the number, average (rounded), min and max salaries for Managers:

SQL

SELECT count(*), round(avg(sal)), min(sal), max(sal) FROM emp WHERE job='MANAGER';

Output

count(*) round(avg(sal)) min(sal) max(sal)
3 2758 2450.00 2975.00

Discussion

MIN() and MAX() also work with character data as do the comparison operators.

Progress

Proceed to Next step