22,209
社区成员
发帖
与我相关
我的任务
分享
select
taskid,
sum(case when step='开始' then [date] else 0 end) as 开始,
sum(case when step='主管审批' then [date] else 0 end) as 主管审批,
sum(case when step='总经理审批' then [date] else 0 end) as 总经理审批
from
tb
group by
taskid
select taskid,sum(case when step ='开始' then date else 0 end) as '开始',
sum(case when step ='主管审批' then date else 0 end) as '主管审批',
sum(case when step ='总经理审批' then date else 0 end) as '总经理审批'
from tb
group by taskid
select
taskid,
sum(case when step='开始' then 1 else 0 end) as 开始,
sum(case when step='主管审批' then 1 else 0 end) as 主管审批,
sum(case when step='总经理审批' then 1 else 0 end) as 总经理审批
from
tb
group by
taskid