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