Introducing PopSQL + dbt. The first SQL editor with built-in dbt support.Read more →

How to Have Multiple Counts in Redshift

To do multiple counts in one query in Redshift, you can combine COUNT() with CASE:

  count(1), -- count all users
  count(case when gender = 'male' then 1 else 0 end), -- count male users
  count(case when beta = true then 1 else 0 end) -- count beta users
  count(case when beta = false then 1 else 0 end) -- count active non-beta users
from users;

Ready for a modern SQL editor?