I have the following fields: user_id, app_mod, profile, update_date.
The first three fields can be duplicated (i.e. two rows could have user_id, app_mod and profile equals, but different update_date):
user_id app_mod profile update_date
560047 RI03290 22809 14-GEN-10
560047 RI03290 22809 18-GEN-10
How can I get the one row with higher update_date in an Oracle environment?
560047 RI03290 22809 18-GEN-10
If the table really only has 4 columns
If the table has other columns as well that you’re not including and that will not be duplicated that you do want returned
The analytic function
rankwill assign multiple rows the same rank if there are ties (i.e. the two rows have the sameuser_id,app_mod,profile, andupdate_date). You could userow_numberinstead which would arbitrarily break the tie. But that would not generally be a repeatable process– Oracle might pick one of the two rows today and another row tomorrow. If you were looking for rows other than the most recent row, you might also look atdense_rankbut that will behave identically torankif you’re just looking for the most recent row.