Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select top 3 within a group
Message
De
16/06/2006 20:07:20
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Select top 3 within a group
Divers
Thread ID:
01129690
Message ID:
01129690
Vues:
84
Hi all,

I have a mytable with 2 fields:

team score
AAAA 10
AAAA 12
AAAA 14
AAAA 16
AAAA 18
AAAA 20
AAAA 22

BBBB 11
BBBB 22
BBBB 33
BBBB 44
BBBB 55
BBBB 66

CCCC 22
CCCC 77
CCCC 88
CCCC 99

DDDD 10
DDDD 12

to have in mynewtable AT LEAST the top 3 in each team if that team has more
than 3 records.

team score
AAAA 22
AAAA 20
AAAA 18


BBBB 66
BBBB 55
BBBB 44

CCCC 99
CCCC 88
CCCC 77

DDDD 12
DDDD 10

I try this SQL statement but not work.
SELECT TOP 3 TEAM,SCORE FROM MYTABLE WHERE TEAM IN ( SELECT TEAM,SCORE FROM MYTABLE ORDER BY TEAM, SCORE DESC;
Please assist to correct my sql.

TIA
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform