This is how my table data looks like ,
Id C1 C2 C3
-------------------------------------------------
1 John 1990 A
2 John 1990 B
3 John 2000 C
4 Mary 2001 D
5 Mary 2010 E
6 Mary 2010 F
7 Jack 2010 G
8 Jack 2010 H
9 Jack 2011 I
What I want to do is I want to group by C1,C2 columns and get the first items of each group which is order by C3
column descending.
So the result will be like
Id C1 C2 C3
-------------------------------------------------
1 John 1990 B
3 John 2000 C
4 Mary 2001 D
5 Mary 2010 F
7 Jack 2010 H
9 Jack 2011 I
And I also want to filter row number 2 to 5 using skip
and take
function.
So the Final result should be like
Id C1 C2 C3
-------------------------------------------------
3 John 2000 C
4 Mary 2001 D
5 Mary 2010 F
7 Jack 2010 H
What I have tried is
await data.GroupBy(d => new { d.C1, d.C2 }).Skip(1).Take(4).FirstAsync();
But it only retrun one row.
How can I solve for this ?