select a.* from ( select cname,id,rnum = ROW_NUMBER() OVER(order by id) from tablename )a where a.rnum = 2
oracle:
select a.* from ( select cname,id,rownum rnum from tablename order by id ) a where a.rnum = 2 [解决办法] Sql语句可以实现你查询的数据集合的第一个值first(),最后一个last(),最大值max()、最小值min()和中间值mid()的。 还有其它的一些方法可以参考http://www.w3schools.com/sql/default.asp [解决办法] select * from(select rows= ROW_NUMBER() OVER(order by id) from table)a where a.rows=cast(ceiling(rand() * (select count(*) from table)) as int)