局站网管能耗.sql 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. with
  2. rru as (select * from sqmdb_cost.nenghao_rru),
  3. bbu as (select * from sqmdb_cost.nenghao_bbu)
  4. select smonth,station_sid,sum(nh_kwh_total) as nh_total
  5. from(
  6. --aau
  7. select smonth,station_sid,'AAU_5G' as stype,sum(nh_kwh) as nh_kwh_total from
  8. (select station_sid,cell_oid,siteid,kid --AAUµÄÊÇ¿òºÅ
  9. from sqmdb_cost.station_aau) sa
  10. join
  11. (select * from rru where net_type ='5G') wg
  12. on sa.siteid=wg.siteid and sa.kid=wg.kid
  13. group by smonth,station_sid
  14. union all
  15. --rru
  16. select smonth,station_sid,'RRU_4G' as stype,sum(nh_kwh) as nh_kwh_total from
  17. (select distinct station_sid,cid,
  18. (regexp_split_to_array(cid,'\.'))[2] as siteid,
  19. (regexp_split_to_array(cid,'\.'))[3] as ci
  20. from
  21. (select station_sid,unnest(string_to_array(cell_oid,'|')) as cid from sqmdb_cost.station_rru) r ) sr
  22. join
  23. (select * from rru where net_type ='4G') wg
  24. on sr.siteid=wg.siteid and sr.ci=wg.ci
  25. group by smonth,station_sid
  26. union all
  27. --bbu_4g
  28. select smonth,station_sid,'BBU_4G' as stype,sum(nh_kwh) as nh_kwh_total
  29. from
  30. (select b4.smonth,r2.station_sid,se.enodeb_id,b4.nh_kwh
  31. from sqmdb_cost.sc_enodeb se
  32. join sqmdb_cost.roomid ri
  33. on se.room_id=ri.room_id
  34. join sqmdb_cost.room r2
  35. on ri.room_sid=r2.room_sid
  36. join
  37. (select * from bbu where net_type ='4G') b4
  38. on se.enodeb_id=b4.siteid) wg4b
  39. group by smonth,station_sid
  40. union all
  41. --bbu_5g
  42. select smonth,station_sid,'BBU_5G' as stype,sum(nh_kwh) as nh_kwh_total
  43. from
  44. (select b5.smonth,r2.station_sid,sg.gnodeb_id,b5.nh_kwh
  45. from sqmdb_cost.sc_gnodeb sg
  46. join sqmdb_cost.roomid ri
  47. on sg.room_id=ri.room_id
  48. join sqmdb_cost.room r2
  49. on ri.room_sid=r2.room_sid
  50. join
  51. (select * from bbu where net_type ='5G') b5
  52. on sg.gnodeb_id=b5.siteid) wg5b
  53. group by smonth,station_sid) uni
  54. group by smonth,station_sid
  55. select * from v_station_omc_nh where smonth='202203'
  56. --create table sqmdb_cost.rpt_station_nh_month_uni as
  57. select smonth,station_sid,'AAU_5G' as stype,sum(nh_kwh) as nh_kwh_total from
  58. (select station_sid,cell_oid,siteid,kid --AAUµÄÊÇ¿òºÅ
  59. from sqmdb_cost.station_aau) sa
  60. join
  61. (select * from sqmdb_cost.nenghao_rru nr where net_type ='5G' and smonth='202204') wg
  62. on sa.siteid=wg.siteid and sa.kid=wg.kid
  63. group by smonth,station_sid