select
*
from
(select
a.resultid,
a.dataid,
a.tiptext,
b.title,
b.content,
b.issuetime,
b.url,
rownum as rn
from
r_resultnews a
left join
v_chn_news b
on a.dataid=b.dataid
where
a.classid=2378
and siteid in (
select
siteid
from
tg_eventstatic
where
datatype=1
and eventclass=2378
and positionid='北京'
)
and rownum>0
)
where
rn>0
and rn<=30
*
from
(select
a.resultid,
a.dataid,
a.tiptext,
b.title,
b.content,
b.issuetime,
b.url,
rownum as rn
from
r_resultnews a
left join
v_chn_news b
on a.dataid=b.dataid
where
a.classid=2378
and siteid in (
select
siteid
from
tg_eventstatic
where
datatype=1
and eventclass=2378
and positionid='北京'
)
and rownum>0
)
where
rn>0
and rn<=30
解决方案 »
- set serverout on,切换用户后dbms_output.put_line(...)没有输出
- oracle中 desc employees 查询表结构 说 无效 sql 语句
- oracle 10G 安装到35%时停止了 一直不再往下进行了
- 触发器求教,请先生教我!
- oracle
- OES下为什么就一个数据库?
- 删除表分区---可能的失败原因征集
- oracle8.0.5 客户端能装到98吗
- 现在8.05的客户端可以连接9i的服务器吗?
- 在线请教sql:select rownum,a from tbl where rownum>10 and rownum<200
- oracle数据库数据移动
- 集合运算符使用列别名排序问题,请帮忙。
SELECT *
FROM (SELECT A.RESULTID,
A.DATAID,
A.TIPTEXT,
B.TITLE,
B.CONTENT,
B.ISSUETIME,
B.URL,
ROWNUM AS RN
FROM R_RESULTNEWS A
LEFT JOIN V_CHN_NEWS B
ON A.DATAID = B.DATAID
WHERE A.CLASSID = 2378
AND EXISTS(SELECT 1 FROM TG_EVENTSTATIC c
WHERE a.SITEID=c.SITEID
AND DATATYPE = 1
AND EVENTCLASS = 2378
AND POSITIONID = '北京')
AND ROWNUM > 0)
WHERE RN > 0
AND RN <= 30这样会不会好点
-- from (
select a.resultid,
a.dataid,
a.tiptext,
b.title,
b.content,
b.issuetime,
b.url,
rownum as rn
from r_resultnews a
left join v_chn_news b on a.dataid = b.dataid
where a.classid = 2378
and exists (select 1 from tg_eventstatic
where datatype = 1
and eventclass = 2378
and positionid = '北京')
and rn <= 30--由于子句中未做排序 外面再包一层没有任何区别不是吗 一句的效率肯定比两句高
/*--修改原则 exists 效率高于left join 高于in
and siteid in (select siteid
from tg_eventstatic
where datatype = 1
and eventclass = 2378
and positionid = '北京')
*/
--and rownum > 0 --这个条件任何时间都有效 不需要写
-- )
-- where rn > 0
-- and rn <= 30