Home > DeveloperSection > Forums > Customer Order Monthly Report Using Pivot In SQL Server
Ankit Singh

Total Post:341

Posted on    December-08-2015 9:15 PM

 Database SQL Server  SQL  SQL Server 2008  SQL Server 2012 

 1 Reply(s)
 629  View(s)
Rate this:
 I want to Customer Order Monthly Report Using Pivot In SQL Server Please help me

aditya kumar Patel

Total Post:254

Posted on    December-08-2015 9:20 PM

Pivot query help us to generate an interactive table that quickly combines and compares large amounts of data. We can rotate its rows and columns to see different summaries of the source data, and we can display the details for areas of interest at a glance. It also help us to generate Multidimensional reporting.

  SELECT * FROM (    
        SELECT c.CustomerName, CONVERT(CHAR(4), d.Orderdate, 100)  as [month],   
            ISNULL(d.amount,0) AS Amount   
            FROM [Order] d RIGHT JOIN Customer c   
            ON d.CustomerID=c.CustomerID)   
            AS s  PIVOT ( SUM(Amount)   
            FOR [Month] in (Jan, Feb, Mar, Apr, May, June, Jul, 
                             Aug, Sep, October, Nov, Dec)
        ) as CustomerOrder order by CustomerName

Don't want to miss updates? Please click the below button!

Follow MindStick