select veh.id,; veh.internal_id,; loc.Caption,; veh.year,; veh.make,; veh.model,; veh.color,; veh.plate_no,; veh.cur_meter,; veh.vin; from vehicles veh; left outer join locations loc on loc.id = veh.location_id; where not deleted(); order by &cSortOrder; into cursor temp1