Re: SQL brainteaser..FUN!
From: Bruce Horrocks <bh_at_granby.demon.co.uk>
Date: Sat, 25 Feb 1995 20:42:38 +0000
Message-ID: <793744958snz_at_granby.demon.co.uk>
Date: Sat, 25 Feb 1995 20:42:38 +0000
Message-ID: <793744958snz_at_granby.demon.co.uk>
In article <3ikro4$6ao_at_galileo.polito.it>
pbertigl_at_io.com "Paolo Bertiglia" writes:
>(James Richard) wrote:
>..
>> :There is a table with 2 columns:
>> >name char(20), age integer ... call it table T
>> >
>> >We want to find out the AGE that occurs most frequently?
>> >What SQL query would return an answer of 24, not 2?
>> >
>>
>select name, age from t
> where age =( select age from t
> group by age
> having count(*) = (select max (count(*)) from t
> group by age)
> )
Hey, three selects...not bad. Can anyone manage any more? ;-)
Regards,
-- ------------------------------------------------------------------------------- Bruce Horrocks Hampshire, England Object Oriented programmers only need two methods - Create and Scoop-Up bh_at_granby.demon.co.uk -------------------------------------------------------------------------------Received on Sat Feb 25 1995 - 21:42:38 CET