>Hi Naomi
>
>>I think the UDF is messing you up. I see that Sergey already provided a plan to work it out.
>
>Yes, it is the UDF, I tried Sergey's code and same problem, so I took only the inside select and yet a problem, then I removed the UDF and it works.
>
>Any suggestions?
The same idea as before - have an inner select to only get necessary info with group by and then join with the rest of the fields + all UDFs you need. In VFP9 you can do it in one select as I showed a quick sample thread reference (and AFAIK Sergey did too). In previous versions you would have to do it two steps, I think.
If it's not broken, fix it until it is.
My Blog