zoukankan      html  css  js  c++  java
  • 最近七天的数据每天相互对比

    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

  • 相关阅读:
    UNDO表空间损坏导致数据库无法OPEN
    kettle新手教程
    Android ViewStub的使用方法
    【转】如何在ubuntu12.04设置adb驱动
    【转】ubuntu设置PATH----不错
    【转】Git与Repo入门----不错
    【转】Gedit中文乱码
    【转】 Git 常用命令详解(二)----不错
    【转】Android源码下载过程的一些注意事项
    【转】repo sync同步Android 源代码下载到99%出错
  • 原文地址:https://www.cnblogs.com/lmfeng/p/2118098.html
Copyright © 2011-2022 走看看