Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Selecting the first one from a group
Message
De
29/02/2000 00:49:15
 
 
À
29/02/2000 00:30:11
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00338912
Message ID:
00338950
Vues:
17
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform