code_junkie

Sum and Group By in Linq to SQL?

Nov 11th, 2011
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. Select
  2. f.Title,
  3. TotalArea = Sum(c.Area)
  4. From Firms f
  5. Left Join Concessions c on c.FirmID = f.FirmID
  6. Group By f.Title
  7. Order by Sum(c.Area) DESC
  8.  
  9. From f As Firm In Db.Firms _
  10. Order By f.Concessions.Sum(Area)
  11.  
  12. From c In Concessions _
  13. Join f In Firms on f.FirmID equals c.FirmID _
  14. Group by f.Title _
  15. Into TotalArea = sum(c.OfficialArea) _
  16. Order by TotalArea Descending _
  17. Select Title, TotalArea
Add Comment
Please, Sign In to add comment