Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: column length, range of values and ........ decode???

Re: column length, range of values and ........ decode???

From: DA Morgan <damorgan_at_exesolutions.com>
Date: Sat, 25 Jan 2003 07:15:08 -0800
Message-ID: <3E32A9FC.8C640676@exesolutions.com>


Mike Cohen wrote:

> Hi All,
>
> I've been messing around with this issue all week and have now raised
> the white flag. I think I've been close, but I just can't seem to
> nail it.
>
> I am pulling the length of a comment column: length(t1.d_comment)
>
> Now, I want to group the results, thus if a column is less than 15 in
> length, it goes to group A, if it is between 16 and 49 characters, it
> is in group B, and if it is 50 or greater characters, it goes to group
> C. I then want to count how many rows are in each group. I think
> that using a DECODE and possibly a SIGN are in order, but I don't want
> to have a decode for each possible column length value. Any ideas?
>
> Thanks Very Much In Advance,
>
> Mike

Right concept wrong function. Use CASE rather than DECODE as in the following example:

SELECT col,

       CASE WHEN (col = 0) THEN 'A'
       WHEN (col in (1,2) THEN 'B'
       WHEN (col BETWEEN 3 AND 5) THEN 'C'
       WHEN (col BETWEEN 6 AND 65) THEN 'D'
       WHEN (col BETWEEN 66 AND 5000) THEN 'E'
       ELSE 'F'
       END col

FROM table;

Daniel Morgan Received on Sat Jan 25 2003 - 09:15:08 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US