zoukankan      html  css  js  c++  java
  • oracle表的列合并(group by)和行合并(union all)

    
    

    group by

    select a.dn,t.dn dnt,a.BEGIN_TIME,a.R032_001,t.R032_001,a.R032_002,a.R032_003,a.R032_004,
    a.R032_005,t.R032_005,a.R032_006,a.R032_007,a.R032_008,a.R032_009,t.R032_009,a.R032_019,t.R032_019
      from PM_LTE_CELL_3 a, PM_LTE_CELL_3CDLOBAK t
     where a.dn = t.dn
       and a.begin_time = t.begin_time
       and t.begin_time =
           to_date('2019-07-16 10:00:00', 'yyyy-mm-dd hh24:mi:ss')
       and t.dn = 'PLMN=1,AREA=4,TLSNB=275591,TdLtecell=1';

    结果只有1行,但列数多了:

    union all

    select a.dn,a.BEGIN_TIME,a.R032_001,a.R032_002,a.R032_003,a.R032_004,a.R032_005,a.R032_006,a.R032_007,a.R032_008,a.R032_009,a.R032_019
      from PM_LTE_CELL_3 a
     where a.dn = 'PLMN=1,AREA=4,TLSNB=275591,TdLtecell=1'
       and a.begin_time =
           to_date('2019-07-16 10:00:00', 'yyyy-mm-dd hh24:mi:ss')
     UNION ALL
      select a.dn,a.BEGIN_TIME,a.R032_001,a.R032_002,a.R032_003,a.R032_004,a.R032_005,a.R032_006,a.R032_007,a.R032_008,a.R032_009,a.R032_019
              from PM_LTE_CELL_3CDLOBAK a
             where a.dn = 'PLMN=1,AREA=4,TLSNB=275591,TdLtecell=1'
               and a.begin_time =
                   to_date('2019-07-16 10:00:00', 'yyyy-mm-dd hh24:mi:ss')
    

      结果有两行,列数没变:

  • 相关阅读:
    Python基础学习笔记(10)形参 命名空间
    10 练习题:形参 命名空间
    09 练习题:函数、参数
    4.题库
    第三章:构造NFA DFA
    第二章
    第一章
    83.jquery的筛选与过滤
    82.认识jQuery以及选择器
    81.案例 初始化、拖拽、缓冲
  • 原文地址:https://www.cnblogs.com/wangziyi0513/p/11209164.html
Copyright © 2011-2022 走看看