最近七天的数据每天相互对比

select tb7.MM,cpu7,cpu6,cpu5,cpu4,cpu3,cpu2,cpu1 from

(select substr(mi,-5) mm,cpu7 from
(select to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi') mi,avg(PARAMETER_VALUE) cpu7 from SANDBOXUSER.BMC_CPU
where to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi') BETWEEN TO_CHAR ( trunc(SYSDATE - 18), 'yyyy/mm/dd hh24:mi' )
AND TO_CHAR ( trunc(SYSDATE - 17), 'yyyy/mm/dd hh24:mi' )
group by to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi')
order by to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi'))
where  mi like TO_CHAR(trunc(SYSDATE - 18),'yyyy/mm/dd')||'%') tb7 ,

(select substr(mi,-5) mm,cpu6 from
(select to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi') mi,avg(PARAMETER_VALUE) cpu6 from SANDBOXUSER.BMC_CPU
where to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi') BETWEEN TO_CHAR ( trunc(SYSDATE - 17), 'yyyy/mm/dd hh24:mi' )
AND TO_CHAR ( trunc(SYSDATE - 16), 'yyyy/mm/dd hh24:mi' )
group by to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi')
order by to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi'))
where  mi like TO_CHAR(trunc(SYSDATE - 17),'yyyy/mm/dd')||'%') tb6 ,

(select substr(mi,-5) mm,cpu5 from
(select to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi') mi,avg(PARAMETER_VALUE) cpu5 from SANDBOXUSER.BMC_CPU
where to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi') BETWEEN TO_CHAR ( trunc(SYSDATE - 16), 'yyyy/mm/dd hh24:mi' )
AND TO_CHAR ( trunc(SYSDATE - 15), 'yyyy/mm/dd hh24:mi' )
group by to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi')
order by to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi'))
where  mi like TO_CHAR(trunc(SYSDATE - 16),'yyyy/mm/dd')||'%') tb5 ,

(select substr(mi,-5) mm,cpu4 from
(select to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi') mi,avg(PARAMETER_VALUE) cpu4 from SANDBOXUSER.BMC_CPU
where to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi') BETWEEN TO_CHAR ( trunc(SYSDATE - 15), 'yyyy/mm/dd hh24:mi' )
AND TO_CHAR ( trunc(SYSDATE - 14), 'yyyy/mm/dd hh24:mi' )
group by to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi')
order by to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi'))
where  mi like TO_CHAR(trunc(SYSDATE - 15),'yyyy/mm/dd')||'%') tb4 ,

(select substr(mi,-5) mm,cpu3 from
(select to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi') mi,avg(PARAMETER_VALUE) cpu3 from SANDBOXUSER.BMC_CPU
where to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi') BETWEEN TO_CHAR ( trunc(SYSDATE - 14), 'yyyy/mm/dd hh24:mi' )
AND TO_CHAR ( trunc(SYSDATE - 13), 'yyyy/mm/dd hh24:mi' )
group by to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi')
order by to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi'))
where  mi like TO_CHAR(trunc(SYSDATE - 14),'yyyy/mm/dd')||'%') tb3 ,

(select substr(mi,-5) mm,cpu2 from
(select to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi') mi,avg(PARAMETER_VALUE) cpu2 from SANDBOXUSER.BMC_CPU
where to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi') BETWEEN TO_CHAR ( trunc(SYSDATE - 13), 'yyyy/mm/dd hh24:mi' )
AND TO_CHAR ( trunc(SYSDATE - 12), 'yyyy/mm/dd hh24:mi' )
group by to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi')
order by to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi'))
where  mi like TO_CHAR(trunc(SYSDATE - 13),'yyyy/mm/dd')||'%') tb2 ,

(select substr(mi,-5) mm,cpu1 from
(select to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi') mi,avg(PARAMETER_VALUE) cpu1 from SANDBOXUSER.BMC_CPU
where to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi') BETWEEN TO_CHAR ( trunc(SYSDATE - 12), 'yyyy/mm/dd hh24:mi' )
AND TO_CHAR ( trunc(SYSDATE - 11), 'yyyy/mm/dd hh24:mi' )
group by to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi')
order by to_char(SAMPLE_TIMESTAMP_UTC,'yyyy/mm/dd hh24:mi'))
where  mi like TO_CHAR(trunc(SYSDATE - 12),'yyyy/mm/dd')||'%') tb1

where tb1.mm = tb2.mm and tb3.mm = tb2.mm and tb3.mm = tb4.mm and tb4.mm = tb5.mm and tb5.mm = tb6.mm and tb6.mm = tb7.mm

posted @ 2011-07-27 12:23  八神吻你  阅读(302)  评论(0编辑  收藏  举报