Yea, I was hoping against hope that there was a way to construct an INDEX or SQL statement that would solve this problem but I think that it is turning out to be a code solution only problem.
Thanks
Ed
>The problem is that you are missing a field that defines group boundaries. So, you have to first process the records in pure ascending order to determine what the group boundaries are. Then you would have to use that information to process the table again. This seems like it would be a real dog for performance.
>
>The idea would be to process the the records in ascending order and create a cursor, perhaps, defining the group boundaries. Then you would have to JOIN the table back to this cursor in some way, probably with a <= expression.
>
>Alternatively, if your original result could be made into a writable cursor, such that it had a group field that could be written to, you could process it once and fill in the group field, and then INDEX the cursor on group + IIF( AorD = "A",
, ).
>
>None of this sounds appetizing, though.