Deviopath › PostgreSQL

Busy Categories

Medium · Grouping

GROUP BY makes one row per group, and HAVING filters those groups after they are counted. (WHERE runs before grouping, so it cannot use COUNT(*).)

Return category and product_count for every category that has more than 2 products. Sort by product_count descending, then category ascending.

Next: Pricier Than Average