Click here to Skip to main content
15,897,187 members
Articles / Database Development / SQL Server

Using Pivot In SQL for Reporting

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
11 Mar 2011CPOL 7.8K   3  
select * from(SELECT l.Prepared_Date as Prepared_Date , m.Material_Code as Material_Code ,n.Name as Name,n.Description as Description , m.Quantity as Quantity,n.Unit_Of_Measure as Unit_Of_Measure , m.Status as Status...

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
28 Feb 2011pankajupadhyay29 2 alternatives  
Nice and fast way for reporting
Please Sign up or sign in to vote.
15 Mar 2011Kannan K R
select ExDate, SUM(case when Dept='A' then expense else 0 end)[Store A Expense],SUM(case when Dept='B' then expense else 0 end)[Store B Expense],SUM(case when Dept='C' then expense else 0 end)[Store C Expense]from expenseTable where Dept in ('A','B','C') group by ExDate

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions