You can group by the truck, filter on the location and check the result is 2:
select truck
from table
where location in (1, 2)
group
by truck
having count(distinct location) = 2
6
solved select only and only specific record in oracle [closed]