I’m trying to build a SQL statement that will select the highest id but only the top value if duplicates exist.
id – value
- 1491825 – 3339
- 1491824 – 3170
- 1491823 – 3143
- 1491822 – 3422
- 1491821 – 3422
- 1491820 – 3422
- 1491819 – 3422
- 1491818 – 3422
- 1491817 – 3261
- 1491816 – 3170
- 1491815 – 3170
- 1491814 – 3170
- 1491813 – 3170
- 1491812 – 3170
- 1491811 – 3170
- 1491810 – 3170
- 1491809 – 3170
- 1491808 – 3170
- 1491807 – 3251
- 1491806 – 3422
Expected Output:
id – value
- 1491825 – 3339
- 1491824 – 3170
- 1491823 – 3143
- 1491822 – 3422
- 1491817 – 3261
- 1491807 – 3251
See: http://www.sqlfiddle.com/#!3/4ee34/3
Edit. Darn. Beaten to it by astander.