Advertisement
Guest User

Untitled

a guest
Nov 16th, 2015
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1. SELECT tmp.id_meter AS meter_code,
  2. tmp.id_workload AS job_id,
  3. CB.ID_BATCH AS feeder_code,
  4. cm.d_gather AS gathered,
  5. MB.METER_COUNT AS mtr_count,
  6. codes (CM.t_phase) AS phase,
  7. codes (cm.o_prepaid) AS Payment,
  8. codes (cm.t_tension) AS Tension,
  9. CB.ID_FEEDER AS Feeder_Name,
  10. CW.ACTIVITY_NAME AS Substation,
  11. sl.location as SUB_LOCATION,
  12. sl.road as SUB_road,
  13. sl.region as sub_region,
  14. codes (cm.t_manufacturer) AS Manufacturer,
  15. cm.id_premise AS MB_Number,
  16. codes (cm.t_usage) AS Usage,
  17. cm.n_lect AS Readings,
  18. cm.no_meter AS meter_number,
  19. tmp.num_apa AS ICS_MTR_NO,
  20. get_last_reading (tmp.nis_rad, tmp.num_apa) AS LastReadings,
  21. codes(tmp.co_marca) AS Manufacturer,
  22. tmp.nis_rad AS SRN,
  23. GET_USAGE_TYPE (tmp.nis_rad, tmp.num_apa) AS Usage,
  24. tmp.f_inst AS Installed,
  25. tmp.f_lvto AS Removed,
  26. icl.nom_local AS locality,
  27. icm.nom_munic AS municipality,
  28. TRIM (
  29. icf.num_puerta
  30. || ' '
  31. || icj.nom_calle
  32. || ' '
  33. || ict.desc_tipo)
  34. AS address,
  35. icf.ref_dir AS plot_reference,
  36. icf.num_itin AS itinerary,
  37. tmp.nif_apa AS prn,
  38. tmp.aol_pm As aol_PM,
  39. DECODE (TMP.IND_SOURCE,
  40. 'A', 'Apmedida',
  41. 'H', 'HApmedida')
  42. AS Source,
  43. cm.gis_x,
  44. cm.gis_y,
  45. tmp.REVIEW_TYPE as Review_type,
  46. tmp.d_inserted date_inserted
  47. FROM TMP_ADHOC_REVIEW tmp,
  48. cam_meters cm,
  49. cam_batches cb,
  50. fincas@ics.world icf,
  51. tipos@ics.world ict,
  52. callejero@ics.world icj,
  53. localidades@ics.world icl,
  54. municipios@ics.world icm,
  55. bdiv10_meterbox mb,
  56. cam_workloads cw
  57. LEFT JOIN
  58. (SELECT j.codigo AS job_id, s.LOCATION, s.road, j.region
  59. FROM bdi_posicional_adminis.bdiv10_historico_trabajos j,
  60. bdi_posicional_adminis.bdiv10_sec_local s
  61. WHERE j.sec_substation_v10 = '3000:' || s.codigo
  62. AND s.onis_ver = 0) sl ON cw.id_workload = sl.job_id
  63. WHERE tmp.id_meter = cm.id_meter
  64. AND tmp.id_workload = cm.id_workload
  65. AND cm.id_workload = CW.ID_WORKLOAD
  66. AND CW.ID_BATCH = CB.ID_BATCH
  67. AND icf.nif = tmp.nif_apa
  68. AND icf.cod_calle = icj.cod_calle
  69. AND icj.cod_local = icl.cod_local
  70. AND icl.cod_munic = icm.cod_munic
  71. AND icj.tip_via = ict.tipo
  72. and cm.id_premise = mb.codigo
  73. AND tmp.REVIEW_TYPE = 'FLEXI-DATES' and tmp.f_inst >= to_date('201411','yyyymm')
  74. AND tmp.d_inserted = '20151105'
  75. order by tmp.id_workload,tmp.nif_apa,tmp.f_inst desc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement