Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
TOP N in a GROUP BY ?
Message
De
01/07/2005 13:44:47
 
 
À
01/07/2005 10:58:24
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01028182
Message ID:
01028281
Vues:
14
>I need to retrieve the top 2 most current rows (using date) for each group (A, B, C). I have created some sample data and the expected results. Anyone got a solution?
>
>SELECT group, date ;
> FROM temp t1 ;
> WHERE pk IN ;
> (SELECT TOP 2 pk FROM temp t2 ;
> WHERE t2.group = t1.group ;
> ORDER BY date desc)
>*-- Get Queries of this type are not supported
>*-- should get back
>group date
>A 05/01/2005
>A 06/01/2005
>B 02/01/2005
>B 03/01/2005
>C 05/01/2005
>C 06/01/2005
>

The problem is that you can't use TOP n in a correlated subquery. I'll keep pondering on this and see if I can come up with a solution.

Tamar
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform