Take the 2-minute tour ×
pass_id retry_id
1       1
1       2
2       1
2       2
2       3
3       1
3       2

Need to pick up record with MAX(retry_id) within MAX(pass_id).

pass_id retry_id
3       2

Thanks in advance!

share|improve this question
add comment

3 Answers

The easiest way is with order by and just choosing one row:

select t.pass_id, t.retry_id
from (select t.*
      from t
      order by pass_id desc, retry_id desc
     ) t
where rownum = 1

Here is a SQLFiddle.

share|improve this answer
add comment
FROM MyTable
   retry_id = (Select MAX(retry_id) FROM MyTable) AND 
   pass_id = (Select MAX(pass_id) FROM MyTable)
share|improve this answer
add comment

Not positive on oracle syntax, but something like

FROM Table
                 FROM Table)
share|improve this answer
add comment

Your Answer


