Skip to content
Advertisement

SQL count show group by show in column instead of rows

I have a table like this enter image description here

Now my output would like to be

total_rows | completed | incomplete
------------------------------------
7              2            5

How can I achieve that.

Advertisement

Answer

You could use condition aggregation

select count(*) total ,
      sum(completed = 1) completed , 
      sum(completed = 0) incompleted 
from your_table
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement