Advertisement
psi_mmobile

Untitled

Jul 9th, 2020
1,408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 0.74 KB | None | 0 0
  1. --vehicle check
  2. (SELECT vd.vehicle_data_id,
  3.   vd.vehicle_id,
  4.   vd.gps_full_date
  5. FROM vehicle_data vd,
  6.   (SELECT v.vehicle_id,
  7.     MAX(vd.gps_full_date) AS dt
  8.   FROM vehicle_data vd,
  9.     vehicle v
  10.   WHERE vd.vehicle_id = v.vehicle_id
  11.   AND NVL(v.vehicle_status_id,0) = 0
  12.   GROUP BY v.vehicle_id
  13.   ) d
  14. WHERE d.vehicle_id = vd.vehicle_id
  15. AND d.dt           = vd.gps_full_date);
  16.  
  17.  
  18. --person check
  19. (SELECT pd.person_data_id,
  20.   pd.person_id,
  21.   pd.event_date
  22. FROM person_data pd,
  23.   (SELECT p.person_id,
  24.     MAX(pd.event_date) AS dt
  25.   FROM person_data pd,
  26.     person p
  27.   WHERE pd.person_id = p.person_id
  28.   AND NVL(p.person_status_id,0) = 0
  29.   GROUP BY p.person_id
  30.   ) d
  31. WHERE d.person_id = pd.person_id
  32. AND d.dt           = pd.event_date);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement