• Hi,

    Since I don't have sample data to work with I took the AdventurWorks database as my foundation. I am not totally clear how your data looks like but below is what I was able to devise.. maybe it can help you with your code .

    select * from

    (

    select YEAR(ORderDATE) as Year_, MONTH(OrderDate) AS Month_pivot,SalesOrderID

    FROM Sales.SalesOrderHeader

    ) as t

    pivot

    (

    Count(salesOrderID) for month_pivot in ([01],[02],[03],[04],[05],[06],[07],[08],[09],[10],[11],[12])

    ) as p

    ----------------------------------------------------