WHERE |
HAVING |
WHERE clause operates on row data. | The HAVING clause operates on aggregated data. |
In the WHERE clause, the filter occurs before any groupings are made. |
HAVING is used to filter values from a group. |
Aggregate functions cannot be used. | Aggregate functions can be used. |
SELECT column1, column2, ...
FROM table_name
WHERE condition;?
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
HAVING condition
ORDER BY column_name(s);?