  select a.acdyear_number as agencyID,
  
 Case
      when b.vehicle_direction = '01' and b.unit_nbr = '01' then 'NB'
      when b.vehicle_direction = '02' and b.unit_nbr = '01' then 'SB'
      when b.vehicle_direction = '03' and b.unit_nbr = '01' then 'EB'
      when b.vehicle_direction = '04' and b.unit_nbr = '01' then 'WB'
      else 'XX' END as v1initialtraveldirection,
 Case
      when b.vehicle_direction = '01' and b.unit_nbr = '02' then 'NB'
      when b.vehicle_direction = '02' and b.unit_nbr = '02' then 'SB'
      when b.vehicle_direction = '03' and b.unit_nbr = '02' then 'EB'
      when b.vehicle_direction = '04' and b.unit_nbr = '02' then 'WB'
      else 'XX' END as v2initialtraveldirection,
      
    FROM  n46jad.acdi_persons_loc a
  inner join n46jad.acdu_vehicles_loc b
	ON (a.acdyear_number = b.acdyear_number
     and a.occupiedcode = b.unit_nbr)
  inner join n46jad.acdl_crash_loc c
  on (c.acdyear_number = b.acdyear_number)
     where a.positioncode='01'
 ;
