using sql count in a case statement -


i have table , need present output in following fashion.

tb_a:  col1  |  reg_id | rsp_ind  

count of rows rsp_ind = 0 'new' , 1 'accepted'

the output should

new | accepted 9   | 10 

i tried using following query.

select    case when rsp_ind = 0 count(reg_id)end 'new',   case when rsp_ind = 1 count(reg_id)end 'accepted' tb_a 

and m getting output

new | accepted null| 10 9   | null 

could me tweak query achieve output. note : cannot add sum surrounding this. part of bigger program , cannot add super-query this.

select      count(case when rsp_ind = 0 1 else null end) "new",     count(case when rsp_ind = 1 1 else null end) "accepted" tb_a 

you can see output request here


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -