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

  结果有两行,列数没变:

 

 

posted on 2019-07-18 18:20  梓沂  阅读(5374)  评论(0编辑  收藏  举报