Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Selecting the first one from a group
Message
From
29/02/2000 13:14:20
 
 
To
29/02/2000 13:07:47
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00338912
Message ID:
00339279
Views:
28
>>>>>If so, this combination should do it (note slight change in first SQL)
SELECT MIN(PrimaryKey) AS pk, SecondaryKey AS sk ;
>>>>>FROM Table INTO CURSOR TEMP ;
>>>>>GROUP BY 2
>>>>>* now choose smaller of two for first column
>>>>>SELECT EVAL("MIN(pk,sk)") AS pk, sk FROM temp
>>>>
>>>>Thanks to all who helped me on this.
>>>>
>>>>I chose this approach. I guess all approaches sent are good as well. And, the speed is good as well.
>>>
>>>As usual, the Fox gives us *many* ways to solve a problem.
>>
>>And here's one more. The non-SQL approach:
>>
>>INDEX ON SecondaryKey TO whatever UNIQUE
>>COPY FIELDS PrimaryKey,SecondaryKey TO whatever
>
>But that would not always give the *lowest* PrimaryKey for each SecondaryKey, which was part of the requirement.

I must have read it wrong. I thought it was the FIRST instance of PrimaryKey for each SecondayKey that was being sought, not the LOWEST instance.
Previous
Reply
Map
View

Click here to load this message in the networking platform