Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select question
Message
From
29/03/2001 08:34:52
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Miscellaneous
Thread ID:
00489490
Message ID:
00489806
Views:
8
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
Previous
Reply
Map
View

Click here to load this message in the networking platform