Yine bu site sayesinde yazmıştım bu sorguyu. Buyrun, herkes yararlansın:
SELECT KART.CODE AS KODU, KART.DEFINITION_ AS ADI, SUM(TRNS.TOTAL) AS [YILLIK TOPLAM], SUM(CASE WHEN MONTH(TRNS.DATE_) = 1 THEN TRNS.TOTAL END) AS [OCAK], SUM(CASE WHEN MONTH(TRNS.DATE_) = 2 THEN TRNS.TOTAL END) AS [ŞUBAT], SUM(CASE WHEN MONTH(TRNS.DATE_) = 3 THEN TRNS.TOTAL END) AS [MART], SUM(CASE WHEN MONTH(TRNS.DATE_) = 4 THEN TRNS.TOTAL END) AS [NİSAN], SUM(CASE WHEN MONTH(TRNS.DATE_) = 5 THEN TRNS.TOTAL END) AS [MAYIS], SUM(CASE WHEN MONTH(TRNS.DATE_) = 6 THEN TRNS.TOTAL END) AS [HAZİRAN], SUM(CASE WHEN MONTH(TRNS.DATE_) = 7 THEN TRNS.TOTAL END) AS [TEMMUZ], SUM(CASE WHEN MONTH(TRNS.DATE_) = 8 THEN TRNS.TOTAL END) AS [AĞUSTOS], SUM(CASE WHEN MONTH(TRNS.DATE_) = 9 THEN TRNS.TOTAL END) AS [EYLÜL], SUM(CASE WHEN MONTH(TRNS.DATE_) = 10 THEN TRNS.TOTAL END) AS [EKİM], SUM(CASE WHEN MONTH(TRNS.DATE_) = 11 THEN TRNS.TOTAL END) AS [KASIM], SUM(CASE WHEN MONTH(TRNS.DATE_) = 12 THEN TRNS.TOTAL END) AS [ARALIK] FROM LG_001_04_STLINE TRNS LEFT OUTER JOIN LG_001_SRVCARD KART ON TRNS.STOCKREF=KART.LOGICALREF WHERE (TRNS.LINETYPE NOT IN (2, 3)) AND (TRNS.TRCODE IN (4)) AND (TRNS.CANCELLED = 0) GROUP BY KART.CODE, KART.DEFINITION_ ORDER BY KART.CODE
sadece kırmızı ile işaretlediğim yerleri kontrol edin. başka bir şey yapmanıza gerek yok...