Conditional aggregates could be a good example: SUM(CASE WHEN published_date < 2000-01-01 THEN 1 ELSE 0 END) as old_book_count.