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
posted on 2009-09-25 23:00  D.Henry  阅读(263)  评论(0编辑  收藏  举报