Re: Please kindly help (urgent SQL+ question)

From: Jeremy Russell <jrinusa_at_gte.net>
Date: Sat, 20 Jun 1998 12:11:12 GMT
Message-ID: <6mg937$2p9$1_at_news-2.news>


Try this?

	SELECT 60*TRUNC(age/60)+1 ||
	       ' to ' || 60*(TRUNC(age/60)+1) Age_Range,	
	       sum(count) count_in_range
	       FROM people
	       GROUP BY TRUNC(age/60)

No SQL processor to hand so not tested!

Hope it helps....

Lee Ka Wo <leekawo_at_netvigator.com> wrote:

>Dear friends,
>
>I have a SQL plus question. I have a table like this (just five
>records):
>
> Name Age
> ------------ ---
> chan tai man 10
> lee ka wo 20
> young man 21
> old man 60
> old woman 62
>
>
>I want to do a query to count the number of
>people with age <60 (young) and number of people >=60 (old). I hope the
>result will
>be like this:
>
> Count(*) Age_range
> -------- ---------
> 3 young
> 2 old
>
>I wonder whether the following statement can serve my purpose.
>
>select count(*), decode(age, <60,'young',>=60,'old')Age_range from
>people
>
>Please kindly advise. Thanks a lot !!!
>
>Lee Ka wo, Ken
>
>
>
>--
>-------------------------------------------------------
>All people have one thing in common, they are DIFFERENT
>-------------------------------------------------------
>Please visit my homepage (IQ Paradise)
>http://home.netvigator.com/~leekawo
>My ICQ: 996903
Received on Sat Jun 20 1998 - 14:11:12 CEST

Original text of this message