WITH A AS ( SELECT Area, COUNT(1) AS Status FROM sss GROUP BY Area UNION SELECT Area, COUNT(1) AS Status FROM sss1 GROUP BY Area UNION SELECT Area,COUNT(1) AS Status FROM sss2 GROUP BY Area ) SELECT A.AREA,'年' AS Time_dimension,SUM(A.Status) Status FROM A WHERE YEAR(A.Date)=YEAR(GETDATE()) GROUP BY A.AREA UNION SELECT A.AREA,'月' AS Time_dimension,SUM(A.Status) Status FROM A WHERE MONTH(A.DATE) =MONTH(GETDATE()) GROUP BY A.AREA 如何修改 需要给Time_dimension参数 |