Counting by bucket
Once you've labelled rows, you can group by the label. Repeat the CASE in GROUP BY:
SELECT CASE WHEN list_price < 5 THEN 'Budget'
WHEN list_price < 20 THEN 'Standard'
ELSE 'Premium' END AS price_band,
COUNT(*) AS products
FROM products
GROUP BY CASE WHEN list_price < 5 THEN 'Budget'
WHEN list_price < 20 THEN 'Standard'
ELSE 'Premium' ENDIt's long-winded, but it works everywhere.
Other databases: DuckDB, PostgreSQL, MySQL and BigQuery let you write
GROUP BY price_band(orGROUP BY 1, the first column) instead. SQL Server doesn't.