An alternative to GROUP BY would be to use a windowing function, such as row_number() , to get the result. This function creates a unique number, breaking your data into Fld2 and ordering it Fld1 desc :
select Fld1, Fld2, Fld3 from ( select Fld1, Fld2, Fld3, rn = row_number() over(partition by fld2 order by fld1 desc) from yourtable ) d where rn = 1;
See SQL Fiddle with Demo . Sometimes using row_number will be easier if you have additional columns that are unique. This gives the result:
| Fld1 | Fld2 | Fld3 | |------|------|------| | 0 | 1234 | ABC | | 0 | 1235 | DEF | | 3 | 1236 | MNO | | 6 | 1237 | VWX |
Taryn
source share