>>Would this work ?
>>
select distinct myField, recno() as rcno ;
>> from myTable into cursor crsUnique nofilter
>>select * from mytable where recno() in (select rcno from crsUnique)
>
>It sure looks like it would work. Here's a method I came up with that does work but may depend on internal implementation of SELECT-SQL GROUP BY to get correct results.
>
>Suppose I have work orders for parts I make (many-to-many relationship) and I want to create a table containing just the initial work order for each part. I can assume that the lowest work order number for a given part number is the initial work order for that part. So...
>
>
>SELECT partnum,wonum;
> FROM workorders;
> ORDER BY partnum,wonum desc;
> INTO CURSOR uniq_wos NOFILTER
>SELECT partnum,wonum;
> FROM uniq_wos;
> ORDER BY partnum;
> GROUP BY partnum;
> INTO CURSOR uniq_wos
>
>
>This works because (apparently) GROUP BY
selectitem returns the row of the last
selectitem it finds in the source set as the representative row of the group....(makes sense if you're summing, averaging, etc). However, though it stands to reason that GROUP BY should work this way by definition, I do not know if that is a fact ... or it is just the way my version of VFP implements it.
>
>The reason for using two selects is because the selection of the group row apparently occurs prior to ordering the result set.
>
>If anyone can give further information about whether this method is risky or not I'd appreciate it.
It's a fact up till VFP6. I didn't check in VFP7 but can't see a reason fox team would change that.
Cetin