Advertisement
Guest User

Untitled

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