datatable unique rows

  • Thread starter Thread starter chris
  • Start date Start date
C

chris

Hello Group,
I have a datatable with duplicate values in a column and I
need to get distinct rows ordered by <col name>. How do I go abt it without
hitting the db?

Thanks for ur help,
Chris.
 
Hi Chris,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to get distinct rows from a
column with duplicate values and sort it. If there is any misunderstanding,
please feel free to let me know.

As far as I know, there doesn't seem to be a function or an expression for
us to get distinct rows directly from the column. I think we have to go
through each row and get data then compare with existing data to see if it
is duplicated.

However, we can also use some tricks to simplify the compare progress. For
example, we can create a DataTable with a single column. We set a unique
contraint on that column. And then copy data of the original column one by
one to the new column. When duplicate data is copied, an exception will be
thrown. We just swallow that exception and continue. Then we'll get a
column distinct data.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Chris,

Thanks for sharing your experience with all the people here. If you have
any questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top