select CONVERT(varchar(12),BOMApprovedDateTime,23) as '工艺审核日期', BOMApprovedBy as '工艺审核人', sum(case SplitBOMType when 1 then 1 else 0 end) as '2020', sum(case SplitBOMType when 2 then 1 else 0 end) as 'CAD转2020', sum(case SplitBOMType when 3 then 1 else 0 end) as '手工拆单', sum(case SplitBOMType when 4 then 1 else 0 end) as 'CAD转IMOS', --sum(case isnull(DoorBomApprovedDateTime,BOMApprovedDateTime) when 0 then 1 else 0 end) as '门滑' COUNT(id) as '汇总' from dbo.C_Order where CONVERT(varchar(12),BOMApprovedDateTime,23) ='2016-11-30' group by CONVERT(varchar(12),BOMApprovedDateTime,23),BOMApprovedBy -------------------------------------------------------------------------------------------------------------------- select CONVERT(varchar(12),DoorBomApprovedDateTime,23) as '门审核日期', DoorBomApprovedBy as '门审核人', COUNT (DoorBomApprovedBy ) as '滑门' from dbo.C_Order where CONVERT(varchar(12),DoorBomApprovedDateTime,23) ='2016-11-30' group by CONVERT(varchar(12),DoorBomApprovedDateTime,23), DoorBomApprovedBy 怎么把下一个查询添加到上一个查询中去成为一列? |