>Please note: VFP 8
>
>I have a cursor with a Uniq_Key, Version, and isProduction flag. The table is created with a
>SELECT fields FROM table ORDER BY uniqKey, isProduction DESC, version DESC
and some sample data looks like
>Uniq_Key isProd Version
>K1 1 1 <----
>K2 0 3 <----
>K2 0 2
>K2 0 1
>K3 1 3 <----
>K3 0 2
>K3 0 1
>K4 1 2 <----
>K4 0 3
>K4 0 1
>
>Note K4 shows a newer version but the production flag has not been set.
>
>What I need is a way to get the first version for each Uniq_Key
>Uniq_Key Version
>K1 1
>K2 3
>K3 3
>K4 2
>
>Maybe I'm having a super-senior day but I can't come up with anything better than
>SELECT uniq_key,version,RECNO() as recno FROM myCursor INTO CURSOR tmp1
>SELECT uniq_key,min(recno) as recno FROM rlp1 GROUP BY uniq_key INTO CURSOR tmp2
>SELECT tmp1.* from tmp1 JOIN tmp2 ON tmp1.uniq_key = tmp2.uniq_key AND tmp1.recno = tmp2.recno INTO CURSOR tmp3
>
>
>I don't want to rely on RECNO() (although I think it's safe in a single table select).
>
>It seems as if there has to be a better way of doing this.
>
>All suggestions appreciated.........Rich
From the data you provided, this is the way, but where is your Uniq_Key?
What is the PK of this table?
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.