Last active
August 29, 2015 14:15
-
-
Save dotsonjb14/edbc402cfa3e02e6f188 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
var salesPeople = | |
Person | |
.Select(x => new { Name = x.FirstName + " " + x.LastName, x.BusinessEntityID }); | |
SalesOrderHeader | |
.Where(x => x.OnlineOrderFlag == false) | |
.GroupBy(x => new { x.OrderDate.Year, x.SalesPersonID }) | |
.Select(x => new { | |
Key = x.Key, | |
Sales = x.Sum(y => y.SubTotal) | |
}) | |
.Select(x => new { Year = x.Key.Year, SalesPerson = salesPeople.FirstOrDefault(y => y.BusinessEntityID == x.Key.SalesPersonID).Name, Sales = x.Sales }) | |
.OrderByDescending(x => x.Sales) | |
.GroupBy(x => x.Year) | |
.OrderBy(x => x.Key) | |
.Dump(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment