我的查询语句是这样的:
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语句呢?谢谢帮忙!
解决方案 »
- 昨天的数据库面试题,请高手指点。
- 日期转换
- 求教关于数据库脚本转化的问题
- oracle 日期转换问题
- 游标问题??
- 一个sql语句转换的问题,很急,再线等!
- 求:trigger引起的问题,解决办法
- MSSQL的语句charindex(':', filename)-1在Oracle中如何实现,谢谢?
- ALTER SESSION SET SQL_TRACE TRUE'的若干问题
- 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