>for each customer where customer.country='USA' > break by customer.state no-lock: > > if first-of(customer.state) then do: > /* do something with first record */ > end. > > /* do something with records */ > > if last-of(customer.state) then do: > /* do something with last record */ > end. > >end. >>
select ... into crsCustomerRecords order by state,... select distinct state from crsCustomerRecords into crsStates order by 1 select crsStates *-- first state, we're on top. scan select crsCustomerRecords scan while state=crsStates.state * do something while in the middle endscan if eof("crsStates") *-- last state endif endscan