Advertisement
psi_mmobile

Untitled

Jul 9th, 2020
1,362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 0.55 KB | None | 0 0
  1. UPDATE
  2.   (SELECT v.last_vehicle_data_id AS OLD,
  3.     d.vehicle_data_id            AS NEW
  4.   FROM vehicle v,
  5.     (SELECT vd.vehicle_data_id,
  6.       vd.vehicle_id,
  7.       vd.gps_full_date
  8.     FROM vehicle_data vd,
  9.       (SELECT v.vehicle_id,
  10.         MAX(vd.gps_full_date) AS dt
  11.       FROM vehicle_data vd,
  12.         vehicle v
  13.       WHERE vd.vehicle_id = v.vehicle_id
  14.       GROUP BY v.vehicle_id
  15.       ) d
  16.     WHERE d.vehicle_id = vd.vehicle_id
  17.     AND d.dt           = vd.gps_full_date
  18.     ) d
  19.   WHERE d.vehicle_id = v.vehicle_id
  20.   ) t
  21. SET t.OLD = t.NEW;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement