集約関数の値に基づくフィルタリング
having句
You cannot filter on aggregated fields using WHERE. You have to use the HAVING keyword to accomplish this. The way aggregation works is that the software processes record by record, finding which ones it wants to keep based on the WHERE condition.
code: having.sql
SELECT year,
SUM(precipitation) as total_precipitation
FROM station_data
GROUP BY year
HAVING total_precipitation > 30