I have a table with rows that look like this
+---------------+-------------+------+-------+ | ID | Name | EL | STRM | +---------------+-------------+------+-------+ | 1 | Tilley | 1 | 1150 | | 1 | Tilley | 2 | 1170 | | 1 | Tilley | 1 | 1190 | | 2 | Lin | 1 | 1170 | | 2 | Lin | 1 | 1190 | | 3 | Jake | 2 | 1170 | | 4 | Sue | 1 | 1150 | | 4 | Sue | 1 | 1190 | | 5 | Jill | 2 | 1150 | +---------------+-------------+------+-------+ I need to make it so that 1 of every unique ID is in the table, but I need it to be in an order that is not ASC, or DESC.
For instance my main value is 1170, if that value exists then delete all other values and keep that one, But if it does not exist then then next important value is 1190 and finally 1150. In the end the table should look something like this:
+---------------+-------------+------+-------+ | ID | Name | EL | STRM | +---------------+-------------+------+-------+ | 1 | Tilley | 2 | 1170 | | 2 | Lin | 1 | 1170 | | 3 | Jake | 2 | 1170 | | 4 | Sue | 1 | 1190 | | 5 | Jill | 2 | 1150 | +---------------+-------------+------+-------+ I tried order by's but I can't seem to get a SQL statement that can do this, and I want to avoid a cursor since its a rather big file. Any ideas?