şu kod bir başlangıç noktası olabilir belki:
SELECT TOP (1000) CLNTC.DEFINITION_ AS [MÜŞTERİ ÜNVANI], SUM(STRNS.AMOUNT) AS [2012 YILLIK TOPLAM], MAX(STFIC.DATE_) AS [2012 SON İŞLEM],
SUM(CASE WHEN MONTH(STFIC.DATE_) = 1 THEN STRNS.AMOUNT END) AS [2012 OCAK], SUM(CASE WHEN MONTH(STFIC.DATE_)
= 2 THEN STRNS.AMOUNT END) AS [2012 ŞUBAT], SUM(CASE WHEN MONTH(STFIC.DATE_) = 3 THEN STRNS.AMOUNT END) AS [2012 MART],
SUM(CASE WHEN MONTH(STFIC.DATE_) = 4 THEN STRNS.AMOUNT END) AS [2012 NİSAN], SUM(CASE WHEN MONTH(STFIC.DATE_)
= 5 THEN STRNS.AMOUNT END) AS [2012 MAYIS], SUM(CASE WHEN MONTH(STFIC.DATE_) = 6 THEN STRNS.AMOUNT END) AS [2012 HAZİRAN],
SUM(CASE WHEN MONTH(STFIC.DATE_) = 7 THEN STRNS.AMOUNT END) AS [2012 TEMMUZ], SUM(CASE WHEN MONTH(STFIC.DATE_)
= 8 THEN STRNS.AMOUNT END) AS [2012 AĞUSTOS], SUM(CASE WHEN MONTH(STFIC.DATE_) = 9 THEN STRNS.AMOUNT END) AS [2012 EYLÜL],
SUM(CASE WHEN MONTH(STFIC.DATE_) = 10 THEN STRNS.AMOUNT END) AS [2012 EKİM], SUM(CASE WHEN MONTH(STFIC.DATE_)
= 11 THEN STRNS.AMOUNT END) AS [2012 KASIM], SUM(CASE WHEN MONTH(STFIC.DATE_) = 12 THEN STRNS.AMOUNT END) AS [2012 ARALIK]
FROM dbo.LG_001_07_STLINE AS STRNS WITH (NOLOCK) LEFT OUTER JOIN
dbo.LG_001_07_STFICHE AS STFIC WITH (NOLOCK) ON STRNS.STFICHEREF = STFIC.LOGICALREF LEFT OUTER JOIN
dbo.LG_001_CLCARD AS CLNTC WITH (NOLOCK) ON STFIC.CLIENTREF = CLNTC.LOGICALREF LEFT OUTER JOIN
dbo.LG_001_ITEMS AS ITMSC WITH (NOLOCK) ON STRNS.STOCKREF = ITMSC.LOGICALREF
WHERE (STRNS.SOURCEINDEX IN (0, 1, 2, 3, 4)) AND (STRNS.DATE_ >= CONVERT(dateTime, '1-1-2012', 101)) AND
(STRNS.DATE_ <= CONVERT(dateTime, '12-31-2012', 101)) AND (STRNS.CPSTFLAG <> 1) AND (STRNS.DETLINE <> 1) AND (STRNS.LINETYPE NOT IN (2, 3)) AND
(STRNS.TRCODE IN (
) AND (STFIC.CANCELLED = 0)
GROUP BY CLNTC.DEFINITION_
ORDER BY '2012 YILLIK TOPLAM' DESC