pass_id retry_id
1 1
1 2
2 1
2 2
2 3
3 1
3 2
需要在MAX(pass_id)内使用MAX(retry_id)获取记录。
pass_id retry_id
3 2
提前致谢!
答案 0 :(得分:1)
最简单的方法是使用order by
并选择一行:
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是一个SQLFiddle。
答案 1 :(得分:0)
SELECT *
FROM MyTable
WHERE
retry_id = (Select MAX(retry_id) FROM MyTable) AND
pass_id = (Select MAX(pass_id) FROM MyTable)
答案 2 :(得分:0)
对oracle语法不是肯定的,但是像
那样SELECT MAX(retry_ID)
FROM Table
WHERE Pass_ID = (SELECT MAX(Pass_ID)
FROM Table)