在Plsql中选择第二行 [英] select 2nd row in Plsql
本文介绍了在Plsql中选择第二行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我们说一下下表:
SomeTable(
id,
price
)
如何从此表中选择价格第二高的行? 注意:这必须在Pl/SQL中以数据库不可知的方式完成. 是否有可能做到这一点而没有任何循环?
How do I select the 2nd highest priced row from this table? Note : This has to be done in Pl/SQL, in a database agnostic way. Is it possible to do this without any loops?
- 我知道如何使用像
rownum
这样的Oracle结构或像limit
这样的mysql结构来完成此操作,所以我不需要这些.
- I know how this is done using Oracle constructs like
rownum
or mysql constructs likelimit
, so I am not looking for those.
推荐答案
这不是很简单吗?上帝知道为什么我以前没有考虑过!
Isn't this simple? God knows why I didn't think about it before!
从tnum中选择max(price) 价格<>(从tnum中选择max(price))
select max(price) from tnum where price <> (select max(price) from tnum)
这篇关于在Plsql中选择第二行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文