If you query directly from this table, you can use PIVOT but you need add more column TransactionDate into transaction table.
CREATE TABLE TransactionSales
(
TransactionID int,
ItemID int,
ItemName nvarchar(100),
Price numeric,
Quantity int,
TotalAmount numeric,
TransactionDate date
)
INSERT INTO TransactionSales
VALUES (1,1,'Sock',20,12,240.00,'2014-01-08'),
(2,2,'Nike Shoes',200,2,400.00,'2014-01-08'),
(3,1,'Sock',10,20,200.00,'2014-08-08'),
(4,2,'Nike Shoes',250,2,500.00,'2014-08-08'),
(5,1,'Sock',20,10,200.00,'2014-02-08')
SELECT ItemName,[1] AS 'Jan',[2] AS 'Feb',[3] AS 'Mar',[4] AS 'Apr',[5] As 'May',[6] As 'Jun',[7] AS 'Jul',[8] As 'Aug',[9] AS 'Sep',[10] As 'Oct',[11] AS 'Nov',[12] AS 'Dec'
FROM
(SELECT ItemName,MONTH(TransactionDate) AS MonthID,SUM(Quantity) AS Quantity
FROM TransactionSales
GROUP BY ItemName,MONTH(TransactionDate)
) AS SourceTable
PIVOT
(
SUM(Quantity) FOR MonthID IN([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12]) )
AS PivotTable;
If you need to query data from reporting tables, I suggest that you create reporting tables such ItemDaily / ItemMonthly and so on.
ItemDaily: rollup data from transaction table and group by ItemID,ItemName and TransactionDate
ItemMonthly: rollup data from ItemDaily
If you need more performance, you could create more summary tables such as ItemQuarterly, ItemMonthToDate,Item_YearToDate to serve your purpose of reporting.
item_quantity
over 12 months.