写成两列不就完了。。selectsid,api,sum(case when flag=0 then count else 0 end) count1,sum(case when flag=1 then count else 0 end) count2from table group by sid,api;
写成两列不就完了。。
select
sid,api,
sum(case when flag=0 then count else 0 end) count1,
sum(case when flag=1 then count else 0 end) count2
from table
group by sid,api;