关于oracle 语句,in 的用法我有一堆数据大概有几万条,按照时间排序的.现在我想取其中的8000条,取升序6000条,降序2000条.就是取头和尾的.但是我这样写报错SELECT sbsfz,sbxm,zdbh,CJBH FROM cc_compare WHERE yhbz='06' AND vhdbz='0' AND cjzt='100' and zjlx='1' AND length(sbsfz)=18 and sbsfz in (SELECT sbsfz FROM cc_compare WHERE yhbz='06' AND vhdbz='0' AND cjzt='100' and zjlx='1' AND length(sbsfz)=18 AND ROWNUM 扫码下载作业帮搜索答疑一搜即得

问题描述:

关于oracle 语句,in 的用法
我有一堆数据大概有几万条,按照时间排序的.现在我想取其中的8000条,取升序6000条,降序2000条.就是取头和尾的.但是我这样写报错
SELECT sbsfz,sbxm,zdbh,CJBH FROM cc_compare WHERE yhbz='06' AND vhdbz='0' AND cjzt='100' and zjlx='1' AND length(sbsfz)=18 and sbsfz in (SELECT sbsfz FROM cc_compare WHERE yhbz='06' AND vhdbz='0' AND cjzt='100' and zjlx='1' AND length(sbsfz)=18 AND ROWNUM

扫码下载作业帮
搜索答疑一搜即得

你的写法效率很低的
select * from
(SELECT sbsfz,sbxm,zdbh,CJBH
FROM cc_compare
WHERE yhbz='06' AND vhdbz='0' AND cjzt='100' and zjlx='1' AND length(sbsfz)=18 and
order by cjpc asc)
where rownum