Re: SQL brainteaser..FUN!

From: Kathleen McSpurren <kmcspurr_at_watarts.uwaterloo.ca>
Date: Fri, 17 Feb 1995 19:27:03 GMT
Message-ID: <D45sp4.n9_at_watserv2.uwaterloo.ca>


In article <3i2lon$46i_at_homer.alpha.net>, Saad Ahmad <sahmad_at_mfa.com> wrote:
>Walter Marek (wmarek_at_grci.com) wrote:
>> Here is some sample data :
>> Tom,24
>> Dick,40
>> Harry,41
>> Sally,24
>> Mary,35
>> Suzy,29
>> We want to find out the AGE that occurs most frequently?
>> What SQL query would return an answer of 24, not 2?
>> a copy to wmarek_at_grci.com
>
>I think this should work:
>select age
>from table
>group by age
>having count(*) = (select max(count (*))
> from table
> group by age )
>
On ZIM's version SQL, this does not give the correct answer. Received on Fri Feb 17 1995 - 20:27:03 CET

Original text of this message