SQL grouped category counts

Count records by category, skipping NULL values.

Original Pearto instructional example. Test it in your own environment and adapt it to your requirements.

SELECT category, COUNT(*) AS total
FROM resources
WHERE category IS NOT NULL
GROUP BY category
ORDER BY total DESC, category ASC;