Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. SELECT SalesPersonID "pracID",
  2. SUM((case when YEAR(OrderDate)=2011 then TotalDue else null end)) "2011",
  3. SUM((case when YEAR(OrderDate)=2012 then TotalDue else null end)) "2012",
  4. SUM((case when YEAR(OrderDate)=2013 then TotalDue else null end)) "2013",
  5. SUM((case when YEAR(OrderDate)=2014 then TotalDue else null end)) "2014"
  6. FROM Sales.SalesOrderHeader
  7. WHERE SalesPersonID IS NOT NULL
  8. GROUP BY SalesPersonID
  9. ORDER BY SalesPersonID
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement