Hi,
Try:
SELECT T2.[ItemCode],
sum(Case DATENAME(month,T0.DocDate) when 'January' then T1.Quantity else 0 end) as January_Qty,
sum(Case DATENAME(month,T0.DocDate) when 'February' then T1.Quantity else 0 end) as February_Qty,
sum(Case DATENAME(month,T0.DocDate) when 'March' then T1.Quantity else 0 end) as March_Qty,
sum(Case DATENAME(month,T0.DocDate) when 'April' then T1.Quantity else 0 end) as April_Qty,
sum(Case DATENAME(month,T0.DocDate) when 'May' then T1.Quantity else 0 end) as May_Qty,
sum(Case DATENAME(month,T0.DocDate) when 'June' then T1.Quantity else 0 end) as June_Qty,
sum(Case DATENAME(month,T0.DocDate) when 'July' then T1.Quantity else 0 end) as July_Qty,
sum(Case DATENAME(month,T0.DocDate) when 'September' then T1.Quantity else 0 end) as September_Qty,
sum(Case DATENAME(month,T0.DocDate) when 'October' then T1.Quantity else 0 end) as October_Qty,
sum(Case DATENAME(month,T0.DocDate) when 'November' then T1.Quantity else 0 end) as November_Qty,
sum(Case DATENAME(month,T0.DocDate) when 'December' then T1.Quantity else 0 end) as December_Qty
FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
INNER JOIN OITB T3 ON T2.ItmsGrpCod = T3.ItmsGrpCod
WHERE DATENAME(YEAR ,T1.DocDate )= '2014' AND T3.[ItmsGrpNam] = '[%0]'
GROUP BY DATENAME(month,T0.DocDate ),T2.ItemCode, T2.ItemName, T2.OnHand
Thanks & Regards,
Nagarajan