我可以将结果合并为一行吗?

时间:2017-11-11 18:01:19

标签: postgresql case

我的查询是:

select urunbolgesi,sube,
count(case etiket when 'BOŞTA' then 1 else null end) as bosta,
count(case etiket when 'ZİMMET' then 1 else null end) as zimmet,
count(case etiket when 'ISKART' then 1 else null end) as iskart
from tblurun 
where urunadi='CASPER-11'
group by urunbolgesi,sube,etiket,urunadi

我的结果是:

urunbolgesi sube    bosta   zimmet  iskart
A           qwer    0       1       0       
B           asdf    5       0       0       
B           asdf    0       0       1      
B           asdf    0       1       0     

我想要的是:

urunbolgesi sube    bosta   zimmet  iskart
A           qwer    0       1       0       
B           asdf    5       1       1       

我可以将结果与上面的代码结合使用吗?

0 个答案:

没有答案