27,579
社区成员
发帖
与我相关
我的任务
分享
select t3.FItemID as '序列号',t1.fsupplyidname as '客户',
sum(case t1.fdeptidname when '信息部' then t1.fauxqty else 0 end) as '信息部数量',
sum(case t1.fdeptidname when '服务部' then t1.fauxqty else 0 end) as '服务部数量',
sum(case t1.fdeptidname when '桶装部' then t1.fauxqty else 0 end) as '桶装部数量',
sum(case t1.fdeptidname when '社区部' then t1.fauxqty else 0 end) as '社区部数量',
sum(case t1.fdeptidname when '校园部' then t1.fauxqty else 0 end) as '校园部数量'
from vwicbill_8 t1,t_organization t3
where t1.Fdate >= '2008-12-01' AND t1.fdate <= '2008-12-05'
and t1.fitemname like '%水票%'
and t1.fsalestylename='现销'
and t1.fsupplyidname=t3.fname
group by t3.FItemID,t1.fsupplyidname,t1.fdcstockidname
HAVING sum(case t1.fdeptidname when '信息部' then t1.fauxqty else 0 end)<>0
AND sum(case t1.fdeptidname when '服务部' then t1.fauxqty else 0 end)<>0
HAVING 那些字段都不等于0