I need fast and effective method to get three count from one table for statistic on my current personal project. And then I’ve found easy and elegant way to do so:
select count(*) Total,
sum(case when is_approved = 't' then 1 else 0 end) PendingCount,
sum(case when is_rejected = 't' then 1 else 0 end) RejectedCount
You could add group by statement so this code will show you counts for groups. This code I’ve tested in PostgresSQL. I’ll try to test it with Oracle DB and will write an update.