I'm trying to pull all the records in the headway_log table whether there is a matching record in incident_log table or not.
Can someone tell me why I get an error in the right outer join below. Thanks for any assistance.
select a.sched_version, b.sched_version,incident_log_id,a.transit_date_time,a.incident_date_time,a.sched_time,
g.incident_name,g.incident_desc,h.direction_description, hl.scheduled_headway
from incident_log a, trip_timepoint b, trip c,vehicle_schedule d, timepoint_name e, timepoints f,incident_types g,
direction_codes h, headway_log hl
where
a."incident_date_time" >= {ts '2016-03-01 04:00:00' }
AND a."incident_date_time" < {ts '2016-12-03 04:00:00' }
and a.sched_version <> 0
--and a.sched_version <> b.sched_version
and a.trip_id = b.trip_id
and a.tp_id = b.tp_id
and a.trip_id = c.trip_id
and b.sched_version = c.sched_version
--and a.sched_version <> c.sched_version
and a.route_id = c.route_id
and (a.incident_log_id % 2) = 0
and a.sched_version = d.sched_version
and a.tp_id = e.tp_id
and f.tp_id = e.tp_id
and a.incident_type = g.incident_type
and c.end_tpid <> a.tp_id
and h.direction_code_id = a.direction_code_id
and RIGHT OUTER JOIN hl on a.incident_log_id = hl.headway_log_id
ORDER BY a.transit_date_time, a.current_route_id, h.direction_description, b.seq_num, a.tp_id, a.incident_date_time
Can someone tell me why I get an error in the right outer join below. Thanks for any assistance.
select a.sched_version, b.sched_version,incident_log_id,a.transit_date_time,a.incident_date_time,a.sched_time,
g.incident_name,g.incident_desc,h.direction_description, hl.scheduled_headway
from incident_log a, trip_timepoint b, trip c,vehicle_schedule d, timepoint_name e, timepoints f,incident_types g,
direction_codes h, headway_log hl
where
a."incident_date_time" >= {ts '2016-03-01 04:00:00' }
AND a."incident_date_time" < {ts '2016-12-03 04:00:00' }
and a.sched_version <> 0
--and a.sched_version <> b.sched_version
and a.trip_id = b.trip_id
and a.tp_id = b.tp_id
and a.trip_id = c.trip_id
and b.sched_version = c.sched_version
--and a.sched_version <> c.sched_version
and a.route_id = c.route_id
and (a.incident_log_id % 2) = 0
and a.sched_version = d.sched_version
and a.tp_id = e.tp_id
and f.tp_id = e.tp_id
and a.incident_type = g.incident_type
and c.end_tpid <> a.tp_id
and h.direction_code_id = a.direction_code_id
and RIGHT OUTER JOIN hl on a.incident_log_id = hl.headway_log_id
ORDER BY a.transit_date_time, a.current_route_id, h.direction_description, b.seq_num, a.tp_id, a.incident_date_time