首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

SQL SERVER 中的top语句使用oracle怎么写

2012-03-16 
SQL SERVER 中的top语句使用oracle如何写?Talbe TAid name jobTable TBid job numSQL SERVER语法:select *

SQL SERVER 中的top语句使用oracle如何写?
Talbe TA 

id name job

Table TB

id job num 

SQL SERVER语法:

select *,(select top 1 num from TB where job=TA.job) from TA 

求教如何转为oracle 语句

[解决办法]
select id, name, job from TA where id in
(select id from (select id from TB order by num desc) where rownum=1);

[解决办法]
Talbe TA

id name job

Table TB

id job num
select [列名,列名],(select num from TB where job=TA.job and rownum <2) from TA
用 rownum 不是那样回报错要写成
select a,b,c,d,(select 列 from 表)

[解决办法]
select id, name, job from TA where job in
(select job from TB) where rownum<2;

[解决办法]
Key Words---RowNum
[解决办法]

SQL code
select t1.*,t2.numfrom TA t1,(select job,num from TB a where a.rowid = (select max(b.rowid) from TB b where b.job=a.job)) t2where t1.job=t2.job 

热点排行
Bad Request.