Re: SQL brainteaser..FUN!
From: Paolo Bertiglia <pbertigl_at_io.com>
Date: 24 Feb 1995 14:50:44 GMT
Message-ID: <3ikro4$6ao_at_galileo.polito.it>
/
Date: 24 Feb 1995 14:50:44 GMT
Message-ID: <3ikro4$6ao_at_galileo.polito.it>
(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) )
/
Previous post include the name, if you want only the age skip the highest level select.
Paolo Bertiglia & Daniela Rea (from Italy :) Received on Fri Feb 24 1995 - 15:50:44 CET