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')

  结果有两行,列数没变:

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM