Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Selecting the first one from a group
Message
From
29/02/2000 00:49:15
 
 
To
29/02/2000 00:30:11
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00338912
Message ID:
00338950
Views:
14
Let's see if we understand this now:

>I may have a result like this:
>
>000001 000002
>000032 000003
>000034 000003
>000004 000002
>000005 000002
>000056 000003

The first SQL SELECT I gave you would produce this from those numbers:

000001 000002
000032 000003

>So, the final result should be:
>000001 000002
>000003 000003

So you want to extract from the first result set:
1) the MIN of pk & sk for the first column
2) and the exact value of sk for column2?

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
David Stevenson, MCSD, 2-time VFP MVP / St. Petersburg, FL USA / david@topstrategies.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform