Last active
August 29, 2015 14:15
-
-
Save dotsonjb14/7ed67b48f5d2fb4326bb to your computer and use it in GitHub Desktop.
Adventure Sales by Year
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT data.[Year], p.FirstName + ' ' + p.LastName, data.Amount FROM | |
( | |
SELECT DATEPART(Year, OrderDate) as [Year], SalesPersonID, SUM(subtotal) as Amount FROM | |
Sales.SalesOrderHeader | |
WHERE OnlineOrderFlag = 0 | |
GROUP BY DATEPART(Year, OrderDate), SalesPersonID | |
) data | |
INNER JOIN Person.Person as [p] ON data.SalesPersonID = p.BusinessEntityID | |
ORDER BY [Year], Amount DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment