SELECT SUM(DayFact) AS jituangongsi,
SUM(CASE WHEN kuangid = 2 THEN DayFact ELSE 0 END) AS kuangchanliang,
yue
FROM (SELECT KM_KtjcDay.DayFact,
AQ_ServerName.DiffDepartmentName AS kuangming,
AQ_ServerName.DiffDepartment AS kuangid, year(KM_KtjcDay.daydate)
AS nian, month(KM_Ktjcday.daydate) AS yue
FROM KM_KtjcDay INNER JOIN
AQ_ServerName ON
KM_KtjcDay.DiffDepartment = AQ_ServerName.DiffDepartment) biao1
WHERE (nian = '2004')
GROUP BY yue
SUM(CASE WHEN kuangid = 2 THEN DayFact ELSE 0 END) AS kuangchanliang,
yue
FROM (SELECT KM_KtjcDay.DayFact,
AQ_ServerName.DiffDepartmentName AS kuangming,
AQ_ServerName.DiffDepartment AS kuangid, year(KM_KtjcDay.daydate)
AS nian, month(KM_Ktjcday.daydate) AS yue
FROM KM_KtjcDay INNER JOIN
AQ_ServerName ON
KM_KtjcDay.DiffDepartment = AQ_ServerName.DiffDepartment) biao1
WHERE (nian = '2004')
GROUP BY yue