select sdata+data3 from (
select date,sum(data1+data2) sdata from table1
where date='20070722' group by date
) t,table2
where t.date=table2.date
select date,sum(data1+data2) sdata from table1
where date='20070722' group by date
) t,table2
where t.date=table2.date
解决方案 »
- 我以前安装过Oracle 10g,现在oracle 9i安装不了..
- 数据库转移数据出现类型不匹配的问题
- 怎么在控制文件中添加多重引号
- ORACLE有没有与SQL SERVER的查询分析器一样的工具?
- sql server图片字段迁移到oracle无法使用~~高手救火
- 求一视图
- 菜鸟请问几个函数
- 急!!!那位大哥帮帮忙
- 急急!!PB中连接oracle时提示“Error while retrieve text for error ora-12154”?
- oracle trigger 条件的使用
- 想查出一个表中的所有字段名,搜了下原来的贴子,但查不出,为什么?
- 请问如果将sqlserver2000中的存储过程和视图转换至oracle中啊,急~!
select date,sum(data1+data2) sdata from table1
where date='20070722' group by date
) t,(select date,sum(data3) data3 from table2
where date='20070722' group by date ) t2
where t.date=t2.date
table1:
字段:data1,data2,data3,data4,data5
1 3 4 6 2
如何取得同一记录不同字段的最大值(Max=6)
create table table1(dat char(8),data1 number,data2 number);
insert into table1 values('20040722', 5 , 6);
insert into table1 values('20040722' , 7 , 8);
insert into table1 values('20040723' , 1 , 2);
insert into table1 values('20040723' , 7, 2);create table table2(dat char(8),data3 number);
insert into table2 values('20040722', 5);
insert into table2 values('20040723' , 6);
select sum(data1) from (
select dat,data1 from table1
union all
select dat,data2 from table1
union all
select dat,data3 from table2
)
where dat = '20040722';select * from (
select dat,sum(data1) data1 from (
select dat,data1 from table1
union all
select dat,data2 from table1
union all
select dat,data3 from table2
)
group by dat
)
order by data1 desc;
select max(data1) from (
select dat,sum(data1) data1 from (
select dat,data1 from table1
union all
select dat,data2 from table1
union all
select dat,data3 from table2
)
group by dat
)/*
SUM(DATA1)
----------
31已选择 1 行。
DAT DATA1
-------- ----------
20040722 31
20040723 18已选择2行。
MAX(DATA1)
----------
31已选择 1 行。
*/
select largest(data1,data2,data3,data4,data5) from table1;
select greatest(data1,data2,data3,data4,data5) from table1;
where a.date='20040722' and b.date='20040722';
--有时我输入长度太长,执行不了 sql语句基本没有限制,我写过百行的语句,没有问题,你说的sql * PLUS中的输入太长
是因为你没有换行,你写了一部分就可以换行,写完了加一个分号就可以运行表示语句结束。