mysql
正确的写法是 select count() from (select distinct() from ) a ,注意这里面一定要给表起别名 a.
limit取3条 offset 从第二条开始
SELECT count(*) from ( SELECT distinct project from h_record) a
SELECT distinct project from h_record LIMIT 3 OFFSET 2
select count(*) from (select distinct(*) from ) a
oracle
取前十条,查询distinct数量语法和mysql一致
SELECT count(*) from ( SELECT distinct project from h_record) a
sqlStatement = f'SELECT * FROM ({sqlStatement}) WHERE ROWNUM <=10 '
取任意条目
sqlStatement = f'SELECT * FROM (SELECT m.*, ROWNUM NUM FROM ({sqlStatement}) m ) WHERE NUM <= 10000 AND num >5000 '
来自Stack Overflow
SELECT * from
(
select m.*, rownum r
from maps006 m
)
where r > 49 and r < 101
参考
https://stackoverflow.com/questions/4552769/sql-rownum-how-to-return-rows-between-a-specific-range