sql转换成oracle,从标准SQL转换为Oracle语法

我将标准SQL连接转换为旧的Oracle连接语法时遇到问题(请不要问我为什么需要这样做).无论如何,我都希望得到同样的结果,不是:

样本数据:

create table testing (

aid number(8),

bid number(8),

btext varchar(80));

insert into testing values (100,1,'text1a');

insert into testing values (100,2,'text1b');

insert into testing values (100,3,'text1c');

insert into testing values (200,19,'text2b');

insert into testing values (200,18,'text2a');

insert into testing values (300,4324,'text3a');

insert into testing values (500,80,'text4a');

insert into testing values (50,2000,'text5a');

commit;

标准SQL:

select a.*,b.* from testing a

left outer join testing b

on (a.aid = b.aid and a.bid < b.bid)

order by a.aid, b.bid;

AID BID BTEXT AID_1 BID_1 BTEXT_1

50 200 text5a NULL NULL NULL

100 1 text1a 100 2 text1b

100 2 text1b 100 3 text1c

100 1 text1a 100 3 text1c

100 3 text1c NULL NULL NULL

200 18 text2a 200 19 text2b

200 19 text2b NULL NULL NULL

300 432 text3a NULL NULL NULL

500 80 text4a NULL NULL NULL

Oracle SQL:

select a.*,b.* from testing a, testing b

where a.aid = b.aid(+)

and a.bid < b.bid

order by a.aid, b.bid;

AID BID BTEXT AID_1 BID_1 BTEXT_1

100 1 text1a 100 2 text1b

100 2 text1b 100 3 text1c

100 1 text1a 100 3 text1c

200 18 text2a 200 19 text2b

如何使用Oracle的旧式语法获得标准SQL的相同结果?

你可能感兴趣的:(sql转换成oracle)