I need to find how many resources are available in depot when transit arrives. I need to have transit name and resource count on result. I'm using MySQL. I wrote this but it gives me error when adding columns to upper select.
select j.name, m.rescount
(select count(*) as rescount
from depot_resource as m
where j.scheduled_time between m.actual_start and m.actual_end)
from transit as j