GROUP BY can use two columns so each category and status pair gets its own count.
highlighted = computed this step
Input table
Start with sales rows that have both category and status labels.
Sales with status
Group query
Group by category and status together, then count every row in each pair.
GROUP BY category, status
Grouped output
The book rows split into paid and refunded buckets instead of one book bucket.
counts by two keys