Re: Please kindly help (urgent SQL+ question)

From: Ngkc Paul <paulkcng_at_netvigator.com>
Date: Mon, 22 Jun 1998 15:15:29 +0800
Message-ID: <Pine.SOL.3.96.980622150737.829B-100000_at_imsnispc01.netvigator.com>


decode(age, <60,'young',>=60,'old')

if you like to use decode, you need to write more. You need to expand the <60 into another decode. Use the sign function to compare the age with 60 sign(60-age) and then decode the result to determine the age range ie, check positive , zero or negative. I think you should do that.

But you can also use PL/SQL to get thre result.

On Sat, 20 Jun 1998, Lee Ka Wo 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 Mon Jun 22 1998 - 09:15:29 CEST

Original text of this message