两个表的结构和数据如下:
table 1 col1 clo2 col3
A B 90
A C 80
A D 70
A E 60
A F 50table 2 col4 clo5 col6
A we 100
A er 90
A rt 80
A yu 70
A oi 60
最后的结果表为:
table 3 col1 clo2 col3 clo5 col6
A B 90 we 100
A C 80 er 90
A D 70 rt 80
A E 60 yu 70
A F 50 oi 60请教高手!
table 1 col1 clo2 col3
A B 90
A C 80
A D 70
A E 60
A F 50table 2 col4 clo5 col6
A we 100
A er 90
A rt 80
A yu 70
A oi 60
最后的结果表为:
table 3 col1 clo2 col3 clo5 col6
A B 90 we 100
A C 80 er 90
A D 70 rt 80
A E 60 yu 70
A F 50 oi 60请教高手!
解决方案 »
- 急急急..一个简单的sql语句不知道在Orcle中是否能执行..我这边没的Orcle环境。
- 重启电脑后oracle启动无效
- 关于SQL语句Count函数的问题
- PL/SQLPLUS DEVELOPER中的宏,oracle中分区与索引,创建表,分区,索引时的一些参数设置
- .net通过Oledb连接Oracle在本地需要配置是哪些环境?
- oracle9.2 for unix 中怎么启动呀?
- 字符串“拼接”
- 有关OMS的问题
- 在PL/SQL的PACKAGE中,不能用CASE WHEN么
- 菜鸟请教!
- 求*.txt导入到oracle的代码
- oracle 中如何将一张500万数据的表从一个库快速转移到另外一个库
(select rownum rn, t1.* from t1),
(select rownum rn, t2.* from t2)
where rn = rn;
table1 union all table2 on table1.col1=table2.col4
关联的话可用 col1与col4
wildwave 你在这很活跃啊,看样子你工作蛮轻松的嘛
(
select 1 sid,'tom1' sname from dual
union all
select 1 sid,'tom2' sname from dual
union all
select 1 sid,'tom3' sname from dual
union all
select 1 sid,'tom4' sname from dual
union all
select 1 sid,'tom5' sname from dual
union all
select 1 sid,'tom6' sname from dual
),
b as
(
select 1 sid, 21 age from dual
union all
select 1 sid, 22 age from dual
union all
select 1 sid, 23 age from dual
union all
select 1 sid, 24 age from dual
union all
select 1 sid, 25 age from dual
union all
select 1 sid, 26 age from dual
)
select t.rn,max(t.sid),max(t.sname),max(t.age) from
(select rownum RN, a.sid sid, a.sname, 0 age from a
union
select rownum RN,b.sid sid, '' sname,b.age from b) t
group by t.rn
解决了
1 1 tom1 21
2 1 tom2 22
3 1 tom3 23
4 1 tom4 24
5 1 tom5 25
6 1 tom6 26