Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27569

[RESOLVED] Filtering DataTable For Unique Values Based From One Column, Based On A Second Column

$
0
0
First, an example of the data I'm working with:

Code:

Column1    Column2
  C          1
  A          2
  C          3

What I need to do is fill a ListBox with the DISTINCT values from Column1 but keep them in the order they would be sorted in if they were ORDERED BY Column2.

From what I've read, it isn't possible to do this within the SQL Query. If I do

SQL Code:
  1. SELECT DISTINCT Column1 FROM (SELECT TOP 100 Column1, Column2 FROM TABLE ORDER BY Column2) AS Test

the result is in alphabetical order instead of ordered by Column2.

Is it possible to achieve the results I'm aiming for by filtering a DataTable filled with the subquery above?

Viewing all articles
Browse latest Browse all 27569

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>