CUSTOMER ORDER MONTHLY REPORT USING PIVOT IN SQL SERVER

Ankit Singh

Total Post:341

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

  1. aditya kumar Patel

    Post:258

    Points:1840
    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

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!