0
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

提前致谢!

4

3 回答 3

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

是一个 SQLFiddle。

于 2013-07-18T21:16:01.663 回答
0
SELECT * 
FROM MyTable
WHERE
   retry_id = (Select MAX(retry_id) FROM MyTable) AND 
   pass_id = (Select MAX(pass_id) FROM MyTable)
于 2013-07-18T21:13:01.107 回答
0

对 oracle 语法不积极,但类似

SELECT MAX(retry_ID)
FROM Table
WHERE Pass_ID = (SELECT MAX(Pass_ID)
                 FROM Table)
于 2013-07-18T21:16:01.407 回答