有
a表
city 1 2 3 4
开封 20 30 0 50
洛阳 50 0 30 20
许昌 40 60 80 90
b表
city 1 2 3 4
洛阳 50 0 30 20
c表
city 1 2 3 4
开封 20 30 0 50
洛阳 100 0 60 40
许昌 40 60 80 90通过a表和b表得到c表,其中c表中“洛阳”的数据由a表中的“洛阳”的数据和b表中的“洛阳”的数据相加而来
请问这个sql在oracle中怎么写(其中的数字1 2 3 4....代表时间(天),即1号,2号,3号,4号 ....)
a表
city 1 2 3 4
开封 20 30 0 50
洛阳 50 0 30 20
许昌 40 60 80 90
b表
city 1 2 3 4
洛阳 50 0 30 20
c表
city 1 2 3 4
开封 20 30 0 50
洛阳 100 0 60 40
许昌 40 60 80 90通过a表和b表得到c表,其中c表中“洛阳”的数据由a表中的“洛阳”的数据和b表中的“洛阳”的数据相加而来
请问这个sql在oracle中怎么写(其中的数字1 2 3 4....代表时间(天),即1号,2号,3号,4号 ....)
解决方案 »
- oracle 10g升级到11g注意事项
- 一台机器上oracle数据库放到另外一台机器上
- linux下oracle监听端口响应慢,求解决方法
- 哪位大哥能提供个在windows server下的oracle版本下载地址
- 如何查看非本地库
- 请教 sql 中的 order by 子句
- sqlserver2000链接Oracle9.02 表中包含BLOB类型字段,执行SELECT操作出错(不包含BLOB字段)
- 创建表空间时出错:'c:\oracle\oradata\cnc\lgy.ora'出错,无法创建文件,无法打开文件,系统找不到指定的路径!
- 关于过程
- 如何对查询出来的重复列赋空值
- oracle循环游标插入数据丢失
- 谁能给我一个oracle论坛的邀请码呀
insert into a1 select '开封' , 20 , 30, 0 , 50 from dual;
insert into a1 select '洛阳', 50 , 0 , 30 , 20 from dual;
insert into a1 select '许昌' , 40 , 60, 80 , 90 from dual;
commit;
create table b1(city varchar2(20),c1 number, c2 number ,c3 number, c4 number);
insert into b1 select '洛阳', 50 ,0 , 30 , 20 from dual;
commit;create table c as
select a1.city, a1.c1+nvl(b1.c1,0) as c1, a1.c2+nvl(b1.c2,0) as c2, a1.c3+nvl(b1.c3,0) as c3, a1.c4+nvl(b1.c4,0) as c4 from a1
left join b1
on a1.city=b1.city;select * from c;
-----------------执行结果如下------------------------
洛阳 100 0 60 40
许昌 40 60 80 90
开封 20 30 0 50