2011-1118
下面是总结一下几种数据库要查询前n条记录的方法:

1. ORACLE
SELECT * FROM TABLE1 WHERE ROWNUM<=N
HQL: from table1 t order by t.createTime desc where rownum<=n

2. INFORMIX
SELECT FIRST N * FROM TABLE1

3. DB2
SELECT * ROW_NUMBER() OVER(ORDER BY COL1 DESC) AS ROWNUM WHERE ROWNUM<=N
或者
SELECT COLUMN FROM TABLE FETCH FIRST N ROWS O 阅读全文>>
标签: 数据库 前N条记录 阅读:7013