I have a DataTable, I want to Finding MAX and MIN based on Grouping in a DataTable.
Here in group column I want to Retain Max and Min value based on Group and delete rest in the same group
and when group is null just skip that row
| Par Name | Group | Min | Max |
| ADC1 | C_A | - 0.2 | 1 |
| ADC2 | C_A | - 2 | 2 |
| USB1 | C_R | -3 | 3 |
| USB2 | C_R | -4 | 2 |
| Value1 | C_A | -5 | 3 |
| ADC3 | C_A | -2 | 5 |
| Value2 | -4 | 1 |
Output :
| Par Name | Group | Min | Max |
| Value1 | C_A | -5 | 3 |
| ADC3 | C_A | -2 | 5 |
| USB2 | C_R | -4 | 2 |
| USB1 | C_R | -3 | 3 |
| Value | | -4 | 1 |

VulpesPosted Jun 23, 2014, 12:12 PM
Farhan ShariffPosted Jun 24, 2014, 4:20 AM
Farhan ShariffPosted Jun 23, 2014, 11:03 AM
first find minimum in the group and then find the maximum in the group and then delete the rest in the same group. and when group has null just leave it in the table.
Value1 belongs to group C_A and has least value
ADC3 belongs to group C_A and has highest value so they are retained.It is comparing based on Max and Min considering the Par Name fall into same group.
VulpesPosted Jun 23, 2014, 11:01 AM
If, for example, we consider the group C_A:
the smallest of the Min values (ignoring the null value) is - 5 in the row with Par Name = Value1
the largest of the Max values is 4 in the row with Par Name = ADC2
So are you saying that you want to retain these two rows but delete the other two (with Par Names of ADC1 and ADC3)?
Farhan ShariffPosted Jun 23, 2014, 10:40 AM
Just want to search Max and Min group wise.
In one particular group find Max and Min delete other rows with Same group name
When group name is null just leave it like that
VulpesPosted Jun 23, 2014, 10:21 AM
// check it worked
Farhan ShariffPosted Jun 23, 2014, 9:51 AM
So output I will have Max and Min for each group and other rows with Group null
VulpesPosted Jun 23, 2014, 9:36 AM
// check it worked