I am so sorry to bother you all with this but I can not seem to get this perfect directly in SQL. I have a table like this with about 6 million records in it:
NonUniqueID | ValueICareAbout1 | ValueICareAbout2 | OtherValue
1001|10|1000|Blarg
1001|20|1000|Blarg2
2002|5|9999|Something
3003|0|999|Whatever
3003|0|8888|Whatever
Out of the 6 Millon there are about 300K dups. My goal is to write a single query that deletes all dup rows on field NonUniqueID keeping whatever competing record has the greater range of between ValueICareAbout1 and ValueICareAbout2 (scraping the rest of the same NonUniqueID rows).
In my example table Rows 2 and 4 would be deleted
I think this isnt too hard but I can not seem to get it right. Any help would be awesome!