日期:2014-05-17 浏览次数:21197 次
with tb_data as (
select '2013-01-12' oxygentime, 55 eos, 55 pulse, 125 userid from dual union all
select '2012-01-06' oxygentime, 55 eos, 55 pulse, 125 userid from dual union all
select '2013-01-02' oxygentime, 55 eos, 55 pulse, 125 userid from dual union all
select '2013-01-05' oxygentime, 55 eos, 55 pulse, 125 userid from dual union all
select '2013-03-08' oxygentime, 55 eos, 55 pulse, 125 userid from dual union all
select '2013-03-06' oxygentime, 55 eos, 55 pulse, 125 userid from dual union all
select '2013-03-07' oxygentime, 55 eos, 55 pulse, 125 userid from dual
)
select xd-6 "开始日期", xd "结束日期", trunc(avg(eos + pulse), 2) "均值"
from (select t.*, next_day(to_date(oxygentime, 'YYYY-MM-DD'), 7) xd from tb_data t)
group by xd;