Q1.What is the difference between WHERE and HAVING in SQL?
- ▸WHERE filters rows BEFORE aggregation — it cannot reference aggregate functions.
- ▸HAVING filters groups AFTER aggregation — used with GROUP BY.
- ▸Example: SELECT dept, COUNT(*) FROM emp GROUP BY dept HAVING COUNT(*) > 5; — filters departments with more than 5 employees.