I am trying to convert rows to columns using Pivot function. Here is my case
SELECT Month(a.createddate) as month,
count(statusid) as count,b.code
from ServiceRequest a,
where a.createddate between '2009-06-01 00:00:00.000' and '2009-12-30 23:59:59.999'
and a.SRSetnumber like '%DELI%'
group by Month(a.createddate),a.statusid ,b.code
order by Month(a.createddate) ,a.statusid,b.code
Result Set :
month count code
6 8425 DELIVERY
6 20 CANCELLED
i want to use pivot function and convert the result set to
month delivery cancelled
Any help would be greatly appreciated. Writing a reporting query and got stuck up with this .I havent used the pivot before and the help topics is little bit confusing to me.