我的查询语句是这样的:
select S_sampled_date,SP_sampling_point,(sum(decode(R_name,'硫含量',R_value))) as value_lhl from u_sample where S_sampled_date between to_date('2008-1-1','yyyy-mm-dd') and to_date('2008-5-5','yyyy-mm-dd') and to_char(S_sampled_date,'D') -1 in (1,3,5) and S_sampling_point_id = 'LYD2_TQYY' group by S_sampled_date,SP_sampling_point order by value_lhl desc查询出结果是:
S_sampled_date SP_sampling_point value_lhl
2008-1-9 2#原油 0.2
2008-1-2 2#原油 0.18
2008-1-11 2#原油 0.16
2008-1-4 2#原油 0.13
2008-1-7 2#原油 0.06
我的意思是在这个基础上取得最大值,最小值和平均值,根据上面的查询结果应该分别为0.2、0.06、0.146,请问我怎么写oracle语句呢?谢谢帮忙!
select S_sampled_date,SP_sampling_point,(sum(decode(R_name,'硫含量',R_value))) as value_lhl from u_sample where S_sampled_date between to_date('2008-1-1','yyyy-mm-dd') and to_date('2008-5-5','yyyy-mm-dd') and to_char(S_sampled_date,'D') -1 in (1,3,5) and S_sampling_point_id = 'LYD2_TQYY' group by S_sampled_date,SP_sampling_point order by value_lhl desc查询出结果是:
S_sampled_date SP_sampling_point value_lhl
2008-1-9 2#原油 0.2
2008-1-2 2#原油 0.18
2008-1-11 2#原油 0.16
2008-1-4 2#原油 0.13
2008-1-7 2#原油 0.06
我的意思是在这个基础上取得最大值,最小值和平均值,根据上面的查询结果应该分别为0.2、0.06、0.146,请问我怎么写oracle语句呢?谢谢帮忙!
解决方案 »
- Oracle8i到11g,字符集us7ascii到ZHS16GBK转换中文显示为?,求解
- 奇了怪了,导师出了个题,题目都读不懂
- 问一条查询语句哦,会的人帮帮忙吧....
- 请指点
- 如何看ORACLE中一个表和哪些存储过程有关系?
- java.exe错误
- 求救,帮帮忙了,哥哥姐姐们。。。
- 数据库转移应注意那些问题 有道理就有分
- 如何保持Oracle中两个结构一样的表的数据同步或一致
- Oracle触发器
- 一道面试题目,如果Oracle不能运行,如何把里面的数据取出来,放到另一台机器的Oracle
- 哪位大蝦 能給我詳細講一講CONNECT BY的用法,還有 CONNECT BY ROWNUM 和 CONNECT BY LEVEL的區別,謝謝
from
(select S_sampled_date,SP_sampling_point,(sum(decode(R_name,'硫含量',R_value))) as value_lhl from u_sample where S_sampled_date between to_date('2008-1-1','yyyy-mm-dd') and to_date('2008-5-5','yyyy-mm-dd') and to_char(S_sampled_date,'D') -1 in (1,3,5) and S_sampling_point_id = 'LYD2_TQYY' group by S_sampled_date,SP_sampling_point order by value_lhl desc) a
group by SP_sampling_point