mercredi 5 octobre 2016

If else statement in select query

I have query written below If my counter is coming then there should show Yes, if no value is coming then No will be there.Please have a look on query. the output should be as below

   KU      Electrical  
Yes   6       2  
No    1       2  </code>

6 is counter of KU and Yes refers the presence,similarly No is non presence of KU

select SalesChannel.name , 
Transaction.category_id, 
count(Transaction.category_id) as count,   
from outlets Outlet inner join transactions Transaction on Outlet.id = Transaction.outlet_id inner join sale_channels SalesChannel on SalesChannel.id = Outlet.sale_channel_id group by SalesChannel.name

Aucun commentaire:

Enregistrer un commentaire