Databases · Junior · Question 28 of 75
What is the difference between WHERE and HAVING?
- 1They are interchangeable
- 2
HAVINGis only for joins - ✓Correct answer:
WHEREfilters rows before grouping;HAVINGfilters groups after aggregation
Explanation
Example: GROUP BY city HAVING COUNT(*) > 100. You can't use an aggregate in WHERE because aggregates don't exist yet at that stage.