Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT d.vehicle_id, d.last_vehicle_data_id, b.vehicle_data_id
- FROM
- (SELECT v.vehicle_id,
- v.last_vehicle_data_id
- FROM vehicle v,
- vo_vehicle_category vovc
- WHERE v.vo_vehicle_category_id = vovc.vo_vehicle_category_id
- AND NVL(vehicle_status_id,0) = 0
- AND NVL(vovc.is_active,'Y') = 'Y'
- AND v.last_vehicle_data_id IS NOT NULL
- and lower(vovc.name) not like 'old%'
- ) d,
- (SELECT vd.vehicle_data_id,
- vd.vehicle_id,
- vd.gps_full_date
- FROM vehicle_data vd,
- (SELECT v.vehicle_id,
- MAX(vd.gps_full_date) AS dt
- FROM vehicle_data vd,
- vehicle v
- WHERE vd.vehicle_id = v.vehicle_id
- AND NVL(v.vehicle_status_id,0) = 0
- GROUP BY v.vehicle_id
- ) d
- WHERE d.vehicle_id = vd.vehicle_id
- AND d.dt = vd.gps_full_date
- ) b
- where d.vehicle_id = b.vehicle_id
- and d.last_vehicle_data_id != b.vehicle_data_id;
- SELECT d.person_id, d.last_person_data_id, b.person_data_id
- FROM
- (SELECT p.person_id,
- p.last_person_data_id
- FROM person p,
- vo_person_category vopc
- WHERE p.vo_person_category_id = vopc.vo_person_category_id
- AND NVL(person_status_id,0) = 0
- AND NVL(vopc.is_active,'Y') = 'Y'
- AND p.last_person_data_id IS NOT NULL
- and lower(vopc.name) not like 'old%'
- ) d,
- (SELECT pd.person_data_id,
- pd.person_id,
- pd.event_date
- FROM person_data pd,
- (SELECT p.person_id,
- MAX(pd.event_date) AS dt
- FROM person_data pd,
- person p
- WHERE pd.person_id = p.person_id
- AND NVL(p.person_status_id,0) = 0
- GROUP BY p.person_id
- ) d
- WHERE d.person_id = pd.person_id
- AND d.dt = pd.event_date
- ) b
- where d.person_id = b.person_id
- and d.last_person_data_id != b.person_data_id;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement