比如这个
也可以写成
from item in data
group item by item.行业 into x
select (from y in x orderby y.指数 select y).Last() ------解决方案-------------------- 按照你的sql转,是这样的:
var table2 = data.GroupBy(x => x.行业).Select(x => new { 行业 = x.Key, 指数 = x.Max(y => y.指数) });
var query = table2.Select(x => data.First(y => y.行业 == x.行业 && y.指数 == x.指数));