日期:2014-05-18 浏览次数:20566 次
SELECT sum(case when b.Docu_Status='2' then 1 else 0 end) AS 扫描, sum(case when b.Docu_Status='5' then 1 else 0 end) AS 质检, sum(case when b.Docu_Status='11' then 1 else 0 end) AS 总质检, sum(case when b.Docu_Status='14' then 1 else 0 end) AS 完成 FROM UDP_Project as a INNER JOIN UDP_Document as b ON a.Project_Id = b.Docu_ForPro
SELECT sum(case when b.Docu_Status='2' then 1 else 0 end) AS 扫描, sum(case when b.Docu_Status='5' then 1 else 0 end) AS 质检, sum(case when b.Docu_Status='11' then 1 else 0 end) AS 总质检, sum(case when b.Docu_Status='14' then 1 else 0 end) AS 完成, sum(...) as 总计 FROM UDP_Project as a INNER JOIN UDP_Document as b ON a.Project_Id = b.Docu_ForPro
SELECT sum(case when b.Docu_Status='2' then 1 else 0 end) AS 扫描, sum(case when b.Docu_Status='5' then 1 else 0 end) AS 质检, sum(case when b.Docu_Status='11' then 1 else 0 end) AS 总质检, sum(case when b.Docu_Status='14' then 1 else 0 end) AS 完成, count(1) as 总计 FROM UDP_Project as a INNER JOIN UDP_Document as b ON a.Project_Id = b.Docu_ForPro
------解决方案--------------------
SELECT sum(case when b.Docu_Status='2' then 1 else 0 end) AS 扫描,
sum(case when b.Docu_Status='5' then 1 else 0 end) AS 质检,
sum(case when b.Docu_Status='11' then 1 else 0 end) AS 总质检,
sum(case when b.Docu_Status='14' then 1 else 0 end) AS 完成,
count(1) as 总计
FROM UDP_Project as a INNER JOIN UDP_Document as b ON a.Project_Id = b.Docu_ForPro
+++
------解决方案--------------------
SELECT sum(case when b.Docu_Status='2' then 1 else 0 end) AS 扫描, sum(case when b.Docu_Status='5' then 1 else 0 end) AS 质检, sum(case when b.Docu_Status='11' then 1 else 0 end) AS 总质检, sum(case when b.Docu_Status='14' then 1 else 0 end) AS 完成, SUM(case b.Docu_Status when '2' then 1 when '5' then 1 when '11' then 1 when '14' then 1 ELSE 0 END) as 总计 FROM UDP_Project as a INNER JOIN UDP_Document as b ON a.Project_Id = b.Docu_ForPro