delete all but minimal values, based on two columns in SQL Server table

Posted by sqlill on Stack Overflow See other posts from Stack Overflow or by sqlill
Published on 2009-08-24T13:32:51Z Indexed on 2010/04/02 2:23 UTC
Read the original article Hit count: 366

Filed under:
|

how to write a statement to accomplish the folowing?

lets say a table has 2 columns (both are nvarchar) with the following data

col1 10000_10000_10001_10002_10002_10002
col2 10____20____10____30____40_____50

I'd like to keep only the following data:

col1 10000_10001_10002
col2 10____10____30

thus removing the duplicates based on the second column values (neither of the columns are primary keys), keeping only those records with the minimal value in the second column.

how to accomplish this?

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server