select *
from (select rownum rno, t1.*
from (select t.id itemid,
decode(p.id, null, 'no', '', 'no', 'yes') hassetup,
p.id postid,
t.sxzxname sxzxname,
d.deptid deptid,
d.shortname,
p.jjr_yb jjryb,
p.jjr_dw jjrdw,
p.jjr_dz jjrdz,
p.jjr_dh jjrdh
from t_share_permissionitem t
left join website.t_webhall_permissionitem_post p on t.id =
p.sxbh,
t_sys_dept d
where t.department = d.deptid
and d.areaid =
(select areaid
from t_sys_dept
where deptid = '200703100000000001')
and d.deptid = '200608181530081000'
) t1) p
where p.rno > 0
and p.rno <= 10
原来,是最原始的sql里面,order by和外面的rownum冲突了,把里面的order by 去掉,终于成功了
本文介绍了一种常见SQL查询问题的解决方案:当使用ROWNUM进行分页时与ORDER BY子句产生的冲突。通过去除内部查询的ORDER BY子句并调整ROWNUM的位置,成功解决了查询错误。

897

被折叠的 条评论
为什么被折叠?



