17,090
社区成员
发帖
与我相关
我的任务
分享
select code,
max(case when state ='on' then count else 0 end) on,
max(case when state ='off' then count else 0 end) off
from 表
group by code
select code,
max(decode(state,'on',count,0)) on,
max(decode(state,'off',count,0)) off
from 表
group by code
太多例子了!
max+case when