Re: SQL brainteaser..FUN!

From: Saad Ahmad <sahmad_at_mfa.com>
Date: 17 Feb 1995 17:18:15 GMT
Message-ID: <3i2lon$46i_at_homer.alpha.net>


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 )

--
**************************************************************
*                          Saad Ahmad                        *
*                          E-Mail: sahmad_at_mfa.com            *
**************************************************************
Received on Fri Feb 17 1995 - 18:18:15 CET

Original text of this message