Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT SalesPersonID "pracID",
- SUM((case when YEAR(OrderDate)=2011 then TotalDue else null end)) "2011",
- SUM((case when YEAR(OrderDate)=2012 then TotalDue else null end)) "2012",
- SUM((case when YEAR(OrderDate)=2013 then TotalDue else null end)) "2013",
- SUM((case when YEAR(OrderDate)=2014 then TotalDue else null end)) "2014"
- FROM Sales.SalesOrderHeader
- WHERE SalesPersonID IS NOT NULL
- GROUP BY SalesPersonID
- ORDER BY SalesPersonID
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement