Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select top 3 within a group
Message
From
16/06/2006 20:07:20
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Select top 3 within a group
Miscellaneous
Thread ID:
01129690
Message ID:
01129690
Views:
89
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
Next
Reply
Map
View

Click here to load this message in the networking platform