一、DB2:
①.按行号并且按照指定字段降序,取前10条数据SQL
SELECT * FROM (Select 字段1,字段2,字段3,rownumber() over(ORDER BY 指定降序字段 DESC) AS rn from 表名) AS a WHERE a.rn BETWEEN 0 AND 10
②.不需降序取前10条数据SQL
SELECT * FROM (Select 字段1,字段2,字段3,rownumber() over() AS rn from 表名) AS a WHERE a.rn BETWEEN 0 AND 10
注:若查询数据含有重复数据则需用方式①,含有重复数据的字段名则为指定字段
二、Mysql:
select * from table limit 0,10
三、Oracle:
从第0行开始取十条记录数据
select * from (select rownum,name from table where rownum <=10) where rownum > 0
四、SQL SERVER
SELECT TOP 页大小 *
FROM Table
WHERE (ID >
(SELECT MAX(id)
FROM (SELECT TOP 页大小*页数 id
FROM 表
ORDER BY id) AS T))
ORDER BY ID