22,209
社区成员
发帖
与我相关
我的任务
分享
select m.customerid,
m.opt_date,
sum(case m.work_id when 7 then 1 else 0 end) [今日发送],
sum(case m.work_id when 1 then 1 else 0 end) [今日回收]
from Opt_Receive_Send m left join Archives n
on m.gcid = n.gcid
group by m.customerid, m.opt_date
select m.customerid,
m.opt_date,
sum(case m.work_id when 7 then 1 else 0 end) [今日发送],
sum(case m.work_id when 1 then 1 else 0 end) [今日回收]
from Opt_Receive_Send m , Archives n
where m.gcid = n.gcid
group by m.customerid, m.opt_date
select T.*,a.gcid from
(select customerid ,sum(case when work_id='7' then 1 else 0 end) as 今日发送 ,
sum(case when work_id='1' then 1 else 0 end) as 今日回收 from Opt_Receive_Send
group by customerid) T left join Archives a on a.customerid =T.customerid