Reputation: 397
I have a nested group by query like this:
select min(sum_money) as minMon, max(sum_money) as maxMon from
(select sum (money) as sum_money from moneyTable where year >= 2014 group by department) as nest
and I wish to accomplish this in LINQ... ...and I am quite desperate
Upvotes: 0
Views: 65
Reputation: 39376
I assume what you want is the min and max sum of money for all departments:
var nestedquery= (from m in context.MoneyTable
where m.year >= 2014
group m by m.department into g
select g.Sum(e=>e.money)).ToList();
var result= new { minMon= nestedquery.Min(e=>e), maxMon=nestedquery.Max(e=>e)};
Upvotes: 1