Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: column length, range of values and ........ decode???
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
Daniel Morgan Received on Sat Jan 25 2003 - 09:15:08 CST