(a)
select tr_avg_qtd_length(t), tr_avg_qtd_duration(t) 
from trucks tru, table(tru.travels) t
where tru.codigo = 2 and
      (t.trbegin.instant,'DD-MM-YY') = '14-06-10';
(b)
select  dt.branch, dt.base, tr_avg_qtd_length(ft.travel),
	tr_avg_qtd_duration(ft.travel)
from  fact_travel ft, dim_truck dt, dim_time dti
where ft.truck_fk = dt.moid and ft.begintime_fk = dti.timeid and
      dti.year = 2011 and dt.month >= 1 and dt.month <= 6
group by rollup(dt.branch, dt.base);