check_01_nenghao_test.sql 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. --能耗
  2. select
  3. distinct
  4. yn.smonth as 月份,
  5. yn.build_code_short as 能耗系统_局站短ID,
  6. yn.city_name as 能耗系统_地市,
  7. yn.area_name as 能耗系统_区县,
  8. yn.build_name as 能耗系统_局站名称,
  9. yn.accrued_power as 能耗系统_电量,
  10. yn.accrued_cost as 能耗系统_成本,
  11. sn.build_id as 索引表_局站短ID,
  12. sn.station_sid as 索引表_局站ID,
  13. wg.station_sid as 网管能耗_局站ID,
  14. wg.nh_total as 网管能耗,
  15. (case
  16. when sn.build_id is not null and yn.accrued_cost!=0 and yn.accrued_cost is not null and wg.station_sid is not null then '校验正常'
  17. when sn.build_id is null then '有能耗无索引'
  18. when yn.accrued_cost is null or yn.accrued_cost=0 then '有能耗无成本'
  19. when yn.accrued_cost!=0 and wg.station_sid is null then '有能耗有成本,校验有问题'
  20. end) as 问题分类
  21. from
  22. (select * from sqmdb_cost.ytmx_new where build_code_short is not null and smonth='202204') yn
  23. left join sqmdb_cost.station_nenghao_new sn on yn.build_code_short=sn.build_id
  24. left join
  25. (select * from sqmdb_cost.v_station_omc_nh_month where smonth='202204') wg
  26. on sn.station_sid=wg.station_sid
  27. --地市能耗索引表与新对应关系对比
  28. select *,
  29. case when sn.station_sid=snn.station_sid then '对应关系相同' else '对应关系不同' end as check_result
  30. from sqmdb_cost.station_nenghao sn
  31. full outer join sqmdb_cost.station_nenghao_new snn on sn.nh_sid_short=snn.build_id