select 
  o.custid, 
  o.shipdate, 
  o.total,
  avg(a.total) mavg
from ord o, ord a
where a.custid = o.custid
and a.shipdate between o.shipdate -123 and o.shipdate
group by o.custid, o.shipdate, o.total