rownum是oracle系统顺序分配为从查询返回的行的编号,总是从1开始的伪劣。
要想返回一个表中按某一个字段排序后的2-5列,以下写法是错误的:
select * from rcpms_fullnote where rownum between 2 and 5 order by serialid;
可以这么写:
select * from(select rownum row_id,serialid from (select rownum
row_id,serialid,cardnumber from rcpms_fullnote order by serialid)) where row_id between 2 and 5;
注意,上面语句之所以不写成select * from(select rownum
row_id,serialid from rcpms_fullnote order by serialid)) where row_id between 2 and 5; 是由于rownum不应和serialid一起按照order by排序
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9896745/viewspace-915370/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9896745/viewspace-915370/