Advertisement
Guest User

Untitled

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