Hi Team,
How to merge the two data table and Get Count using Group by in linq
while merge the columns not found in previous columns add new columns.
Thanks
Shyam
Hi Team,
How to merge the two data table and Get Count using Group by in linq
while merge the columns not found in previous columns add new columns.
Thanks
Shyam
It would be great of you can give sample input and output.
Dt1
Name | Class |
---|---|
AA | XX |
AA | XX |
BB | YY |
BB | YY |
CC | VV |
Dt2
Name | Class | Leave |
---|---|---|
AA | XX | YY |
BB | YY | YY |
BB | YY | YY |
CC | VV | YY |
DD | TT | YY |
Required Output
Name | Class | Leave | Count |
---|---|---|---|
AA | XX | XX | 3 |
BB | YY | YY | 4 |
CC | VV | VV | 2 |
DD | TT | TT | 1 |
Let us know if this works for you
Add Data Column activity is used to add “Count” Column in dt3
dt3 = (From rw In dt3.AsEnumerable Group rw By k1=rw("Name").ToString.Trim,k2=rw("Class").ToString.Trim Into grp=Group select dt3.Clone.LoadDataRow({grp(0)(0).ToString,grp(0)(1).ToString,grp(0)(2).ToString,grp.Count},True)).CopyToDataTable
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.