Customer Order Monthly Report Using Pivot In SQL Server

Total Post:341

Points:2389
 1013  View(s)
Ratings:
Rate this:
 I want to Customer Order Monthly Report Using Pivot In SQL Server Please help me

  1. Post:282

    Points:2010
    Re: Customer Order Monthly Report Using Pivot In SQL Server

    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

      Modified On Apr-10-2018 06:27:46 AM

Answer