Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select question
Message
De
29/03/2001 08:34:52
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Divers
Thread ID:
00489490
Message ID:
00489806
Vues:
7
I have an another solution.
create table colors (fkey int, color varchar(10), cnt int)

INSERT INTO colors VALUES (1,        'Red',             100)
INSERT INTO colors VALUES (1,        'White',           101)
INSERT INTO colors VALUES (1,        'Blue',            102)
INSERT INTO colors VALUES (2,        'Black',           1001)
INSERT INTO colors VALUES (2,        'Blue' ,           1002)
INSERT INTO colors VALUES (3,        'Purple',          101)
INSERT INTO colors VALUES (3,        'Yellow' ,         102)
INSERT INTO colors VALUES (3,        'Orange'  ,        103)
INSERT INTO colors VALUES (3,       'Blue'      ,      104)

select 
	fkey, color, cnt 
from 
	colors
where
	cnt = (SELECT MAX(cnt) FROM colors c WHERE c.fkey = colors.fkey)
Ignore the messy formatting. I was in a hurry.

-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform