01 / 04
Narrow, then count
"How many items of 1000 or more are there in each category?" narrows the rows first, then gathers. WHERE bites before GROUP BY.
The writing order is fixed the same way: WHERE then GROUP BY.
SELECT category, COUNT(*) AS products FROM items WHERE price >= 1000 GROUP BY category;Result
cleaning | 1 interior | 1 kitchen | 2 stationery | 1