22,293
社区成员
发帖
与我相关
我的任务
分享
select d.fjmc1 as 辅具名称,d.fjbh1 as 产品编号,
sum(case when d.fjsx1='成品' and d.chaptertype='1' then 1 else 0 end ) as A目录,
sum(case when d.fjsx1='成品' and d.chaptertype='2' then 1 else 0 end ) as B目录,
sum(case when d.fjsx1='成品' then 1 else 0 end ) as 合计,
sum(case when d.fjsx1='定制品' or d.fjsx1='改制品' then 1 else 0 end ) as "定改制(件)",
(
case when (SELECT sum(convert(int,cast(b.dj1 as float)) *convert(int,cast(b.sl1 as float)) )
from dsass_zwb_fjkffwxq a INNER JOIN dsassfjfjpsdjb b on a.ida_psdj=b.id where b.fjbh1 is not null and b.chaptertype='1') is null then 0 end
) as A目录a,
(
case when (SELECT sum(convert(int,cast(b.dj1 as float)) *convert(int,cast(b.sl1 as float)) )
from dsass_zwb_fjkffwxq a INNER JOIN dsassfjfjpsdjb b on a.ida_psdj=b.id where b.fjbh1 is not null and b.chaptertype='2') is null then 0 end
) as B目录a ,
((SELECT sum(convert(int,cast(b.dj1 as float)) *convert(int,cast(b.sl1 as float)) )
from dsass_zwb_fjkffwxq a INNER JOIN dsassfjfjpsdjb b on a.ida_psdj=b.id where b.fjbh1 is not null and b.chaptertype='1')+
(SELECT sum(convert(int,cast(b.dj1 as float)) *convert(int,cast(b.sl1 as float)) )
from dsass_zwb_fjkffwxq a INNER JOIN dsassfjfjpsdjb b on a.ida_psdj=b.id where b.fjbh1 is not null and b.chaptertype='2')) as 合计
from dsass_zwb_fjkffwxq c INNER JOIN dsassfjfjpsdjb d on c.ida_psdj=d.id where d.fjbh1 is not null GROUP BY d.fjmc1,d.fjbh1