日期:2014-05-18 浏览次数:20640 次
SELECT COUNT(case when b.Docu_Status='2' then b.Docu_Status else 0 end) AS Expr1, COUNT(case when b.Docu_Status='5' then b.Docu_Status else 0 end) AS Expr2, COUNT(case when b.Docu_Status='11' then b.Docu_Status else 0 end) AS Expr3, COUNT(case when b.Docu_Status='14' then b.Docu_Status else 0 end) AS Expr4 FROM UDP_Project as a INNER JOIN UDP_Document as b ON a.Project_Id = b.Docu_ForPro where a.Project_Djsj between '2011-12-27 0:00:00' and '2012-4-16 0:00:00'
SELECT SUM(case when b.Docu_Status='2' then b.Docu_Status else 0 end) AS Expr1, SUM(case when b.Docu_Status='5' then b.Docu_Status else 0 end) AS Expr2, SUM(case when b.Docu_Status='11' then b.Docu_Status else 0 end) AS Expr3, SUM(case when b.Docu_Status='14' then b.Docu_Status else 0 end) AS Expr4 FROM UDP_Project as a INNER JOIN UDP_Document as b ON a.Project_Id = b.Docu_ForPro where a.Project_Djsj between '2011-12-27 0:00:00' and '2012-4-16 0:00:00'
------解决方案--------------------
SELECT sum(case when b.Docu_Status='2' then 1 else 0 end) AS Expr1, sum(case when b.Docu_Status='5' then 1 else 0 end) AS Expr2, sum(case when b.Docu_Status='11' then 1 else 0 end) AS Expr3, sum(case when b.Docu_Status='14' then 1 else 0 end) AS Expr4 FROM UDP_Project as a INNER JOIN UDP_Document as b ON a.Project_Id = b.Docu_ForPro where a.Project_Djsj between '2011-12-27 0:00:00' and '2012-4-16 0:00:00'