如何用sql语言查询一个表中的第二条记录!!!!

2024-11-05 11:11:06
推荐回答(3个)
回答1:

(select top 2 * from table) a,(select top 1 * from table) b where a.字段!=b.字段(找个肯定不同的字段)
oracle :select * from (select t.*,rownum as num from table where rownum<=2) where num=2

回答2:

SELECT TOP 2 * FROM 表
EXCEPT
SELECT TOP 1 * FROM 表;

SQL Server 下面可以这么写。
其他数据库不行。

回答3:

select * from
(select row_number() over(order by getdate()) as rn,* from tablename) as t
where rn=2