c# - Linq Query Datatable and Group by multiple columns -
suppose have following datatable loaded in memory db query:
col_a: col_b: col_c: col_d: date1: date2: a1 b1 c1 d1 dt1_1 dt2_1 a1 b2 c2 d2 dt1_1 dt2_2 a1 b3 c3 d3 dt1_1 dt2_3 a1 b4 c4 d4 dt1_2 dt2_4 a1 b5 c5 d5 dt1_2 dt2_5 and, in terms of dates, assume, example, "_1" < "_2". so, want is, each value in col_a, 1 row each date1 earliest date2.
so, given data, i'd want back:
col_a: col_b: col_c: col_d: date1: date2: a1 b1 c1 d1 dt1_1 dt2_1 a1 b4 c4 d4 dt1_2 dt2_4 in other words, since date1 changed, data earliest date2. hope makes sense.
in sql i'd kind of imagine query looking follows:
select col_a, col_b, col_c, col_d, date1, date2, rank() over(partition col_a, date1 order date2) rn mytable rn = 1 order col_a, date1, date2 but how create in linq , new datatable (filtered) results?
check out link linq rank() , case when in vb.net , sub link shows date aggregate: linq sql vb.net assistance
Comments
Post a Comment