Re: SQL brainteaser..FUN!
From: Gerard Averill <gaverill_at_chsra4.chsra.wisc.edu>
Date: Fri, 17 Feb 1995 11:36:23
Message-ID: <gaverill.37.000B9BA0_at_chsra4.chsra.wisc.edu>
Date: Fri, 17 Feb 1995 11:36:23
Message-ID: <gaverill.37.000B9BA0_at_chsra4.chsra.wisc.edu>
In article <3i2gj9$mdr_at_shark.sb.grci.com> Walter Marek <wmarek_at_grci.com> writes:
>OK, here is the basic premise. There is a table with 2 columns:
>name char(20), age integer ... call it table T
>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?
[snip]
here's one:
set rowcount 1
select AGE from THE_TABLE group by AGE order by count(*) desc
sometimes that 'set rowcount' is pretty handy, eh? Received on Fri Feb 17 1995 - 11:36:23 CET