select tru.codigo, tr_count(t), tr_avg_duration(t), tr_avg_evt_delivery(t)
from trucks tru, table(tru.travels) t, areas a
where a.name = 'OSASCO' and a.category = 'CITY' and
  sdo_inside(t.get_trline(), a.geometry) = 'TRUE' and
  t.trbegin.instant >= to_timestamp('01-01-2010') and
  t.trend.instant <= to_timestamp('30-06-2010')    
group by tru.codigo;
      