my table looks like- Area MaxRate MinRate Quarter year crossing 1000 800 1 2013 crossing 900 700 2 2013 crossing 800 600 3 2013请帮我在LINQ-lambda表示法
crossing 700 500 4 2013 crossing 600 500 1 2012 crossing 550 450 2 2012 crossing 500 400 3 2012
crossing 450 350 4 2012 indroper 2000 1500 1 2013 indroper 1800 1500 2 2013I want max and min rates for the particular area in current year as - **Area MaxRate MinRate year** crossing 1000 500 2013
中查找查询
答案 0 :(得分:2)
您可以使用GroupBy
执行此操作:
var results = table.GroupBy(row => new { Area = row.Area, Year = row.year })
.Select(g => new {
Area = g.Key.Area,
MaxRate = g.Max(i => i.MaxRate),
MinRate = g.Min(i => i.MinRate),
Year = g.Key.Year
});