给出表格和数据,如
Id Year Code ColB ColC
1 2013 A Foo Bar
2 2014 A Baz Qux
3 2014 B Jax Fizz
4 2013 C Buub Baq
我希望为每个代码选择“最新”行,例如:
Id Year Code ColB ColC
2 2014 A Baz Qux
3 2014 B Jax Fizz
4 2013 C Buub Baq
我看到这可以直接在SQL
中完成select a,b
from (
select a,b,row_number() over(partition by a order by b desc) as roworder
from myTable
) temp
where roworder = 1
https://stackoverflow.com/a/7344770/141172
这可以在Linq to Entities中表达吗?