Hi Agnes,
VFP returns values for the fields not included in the GROUP BY clause from the last physical record in the group not from the record with MAX()/MIN() value.
>SELECT;
> Work_Table.Code,Key_Table.Key,MAX(Ref_Table.Code);
> FROM Work_Table;
> INNER JOIN Ref_Table;
> ON Work_Table.Code=ALLTRIM(Ref_Table.Code);
> GROUP BY 1
>
>
>The result is, that I get the correct Code from Ref_Table, and a wrong Key.
>
>What's wrong with my statement?
>
>Thanks for Help
>
>Agnes
--sb--