>Invoice Number Amount >10001 1,000 > 2,000 > 3,000 >TOTAL 6,000 > >10002 4,000 > >10003 5,000 > 6,000 >TOTAL 11,000 > >GRAND TOTAL 21,000 >>
>Invoice Number Amount Total >10001 1,000 > 2,000 > 3,000 6,000 > >10002 4,000 4,000 > >10003 5,000 > 6,000 11,000 > >GRAND TOTAL 21,000 >In general, preparing all the data beforehand (in a cursor) seems a sensible approach. An alternative is to have a UDF that looks ahead at the next record, to see if there is a change in a certain key expression. But I would prefer preparing all the data beforehand.