Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / database / SQL-Server

Using Pivot In SQL for Reporting

0.00/5 (No votes)
11 Mar 2011CPOL 8.1K  
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)