Scenario- I have 1 datatable which contains columns namely student name, id and marks.
I have to select all the ids if any of the marks is less than 40 related to that student. it may have multiple student names, ids and marks, below table for reference.
Example
Student name Id Marks
Abc 101 55
Abc 102 54
Abc 103 39
Abc 104 56
Xyz 105 66
XYz 106 65
in the above table one of the marks is less than 40 so it has to consider all the ids for Abc.
(From d in YourDataTableVar.AsEnumerable()
Group d by k=d("StudentName").toString.Trim into grp=Group
Where grp.Any(Function (g) CInt(g("Marks").toString.Trim) < 40)
Let idl = grp.Select(Function (x) x("ID").toString.Trim)
Select ids =idl).SelectMany(Function (x) x).toArray
(From row In Dt_input.AsEnumerable()
Group row By studentName = row("Student Name")
Into studentGroup = Group
Where studentGroup.Any(Function(r) Convert.ToInt32(r("Marks")) < 40)
From sg In studentGroup
Select (Convert.ToInt32(sg("ID")).ToString)).ToList
Shared the workflow for reference too. Sequence5.xaml (12.9 KB)