I have a table something similar to :
ID Value1 Value2 122 800 1600 122 800 1800 133 700 1500 154 800 1800 133 700 1500 188 700 1400 176 900 1500 From this table I want to delete the duplicates (ID of 122 and 133) which have a greater difference between value2 and value1.
This means that where ID is 122 I want to keep the first row (1800-800>1600-800) This means that where ID is 133 I want to keep either one because they both have the same difference.
ID Value1 Value2 122 800 1600 122 800 1800 <------delete this row 133 700 1500 <------delete either this row or the other identical row 154 800 1800 133 700 1500 <------delete either this row or the other identical row 188 700 1400 176 900 1500 It is on a much larger scale that this, so I cant just individually delete records.
Is there a way to write a statement that will delete all duplicates from my table where Value2 - Value1 is greater than Value2 - Value1 for its duplicate?