>actually Al i was trying to adapt the 'find duplicates' code that Hilmar sent me for a new task. the new task was to display names for those records with data in the field ex2s and then display those names as a text string - sorry for the confusion.
>exs2 is a numeric field
>vname is a character field which contains a name.
>
>k
>
Please post the input and desired output. In the meantime you may want to read the following blogs (even though they are for SQL Server, some of the techniques can be easily applied to VFP):
Optimizing TOP N per Group Queries - blog by Itzik Ben-Gan explaining various optimization ideas
Including an Aggregated Column's Related Values - Erik and mine blog presenting several solutions of the problem with explanations for each
Including an Aggregated Column's Related Values - Part 2 - my blog post with use cases for the previous blog
If it's not broken, fix it until it is.
My Blog