Click here to Skip to main content
15,885,933 members
Articles / Database Development / SQL Server
Alternative
Tip/Trick

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.7K   3   1
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...
SQL
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 ,l.Requested_By as requester
                FROM mms_store_requisition  l inner join
                mms_store_requisition_detail  m on l.SR_No=m.SR_No
                inner join mms_material  n on m.material_code=n.material_code
                where l.Prepared_Date between '1966-01-01' and '2003-12-12'
                order by m.Status, m.Material_Code)  request
                inner join (select t1.emp_Id as employee,t1.department_id
                ,t2.description as Requestion_Department
                from hr_employee_info t1 inner join tbl_department t2
                on t1.department_id=t2.department_id)  empInfo
                on request.requester=empInfo.employee

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

 
Generalhi Feleke, I could not find this as alternate of pivoting co... Pin
pankajupadhyay2911-Mar-11 2:14
professionalpankajupadhyay2911-Mar-11 2:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.