Aggregation Functions¶
Aggregation functions perform some operations on a set of rows. These include
- Avg
- Min
- Max
- Sum
- Count
Example¶
SELECT count(*) FROM my_table
GROUP BY¶
GROUP BY keyword groups entries by some equality on some attribute * note that whichever attribute you choose to group by must be present in the SELECT clause
HAVING¶
HAVING keyword is the same as where, except it acts after group by
Example¶
SELECT dept_name, avg(salary) as avg_salary
FROM instructor
GROUP BY dept_name
HAVING avg(salary) > 42000;