Link to home
Create AccountLog in
Avatar of k3n51mm
k3n51mm

asked on

VB.Net 2005: Datatable filter

I have a datatable that I need to filter. It's a rather complex filter though (for me anyway), and I'm having serious trouble getting my head around datacolumn filtering and all that. Note that i'm only doing this in VB because the database we must use (SQL Compact Edition) does not support the complex join/subquery required to get this data directly from the db.

Given the datatable:

NAME     RESULT         COMPVALUE
abcd         8                      6                                
efgh         3                       7                                
lmno         9                      2                                
abcd         4                      6                                
lmno         5                      2                                
efgh         4                       7                                
abcd         9                      6                              
                               
I need the following result set, preferably in a new datatable:
abcd         9                      6
efgh         4                       7
lmno         9                      2

For each NAME in the datatable, I need to return the highest RESULT and its COMPVALUE. COMPVALUE is a static value for each NAME and will always be the same.

Trying to break it down, I figured I'd need to get all the rows for each NAME, get the highest RESULT, grab the VALUE, and add it to the output datatable. But when I started looking at the datacolumn filtering docs on MSDN, I just can't understand it all at first glance. I have a deadline. Little help?



ASKER CERTIFIED SOLUTION
Avatar of pitster
pitster
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of k3n51mm
k3n51mm

ASKER

Hey that looks great, I'll try it