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
提前致谢!
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
提前致谢!
最简单的方法是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
这是一个 SQLFiddle。
SELECT *
FROM MyTable
WHERE
retry_id = (Select MAX(retry_id) FROM MyTable) AND
pass_id = (Select MAX(pass_id) FROM MyTable)
对 oracle 语法不积极,但类似
SELECT MAX(retry_ID)
FROM Table
WHERE Pass_ID = (SELECT MAX(Pass_ID)
FROM Table)