COUNT()()
COUNT(*) how many rows (including NULL-filled rows). COUNT(marks) how many non-NULL marks. COUNT(DISTINCT city) how many unique cities.
SELECT city, COUNT(*) FROM students GROUP BY city; class size per city. HAVING COUNT(*) > 10; crowded cities.
Trap — COUNT(1) vs COUNT(*) myths — both count rows. Trap: COUNT(marks) when you meant students including absentees.
On the example next to this theory — COUNT()() — aggregate functions collapse many rows into one summary row.
Exam tip
COUNT(*) all rows. COUNT(marks) only who has marks.