日期:2014-05-17 浏览次数:20439 次
CREATE VIEW xxx AS SELECT g_name , SUM(num) num , SUM(num1) num1 , SUM(num2) num2 FROM ( SELECT g_Name , COUNT(checkName1) Num , 0 AS Num1 , 0 AS Num2 FROM CheckMo WHERE checkName1 <> '无' AND checkTime BETWEEN '2012-10-10' AND '2012-10-20' GROUP BY g_Name UNION ALL SELECT g_Name , 0 AS Num , COUNT(checkName1) Num1 , COUNT(checkName2) Num2 FROM CheckMo WHERE checkName1 <> '无' AND checkName2 <> '无' AND checkTime BETWEEN '2012-10-10' AND '2012-10-20' GROUP BY g_Name UNION ALL SELECT g_Name , 0 AS Num , 0 AS Num1 , COUNT(checkName2) Num2 FROM CheckMo WHERE checkName1 = '无' AND checkName2 <> '无' AND checkTime BETWEEN '2012-10-10' AND '2012-10-20' GROUP BY g_Name ) a GROUP BY g_name