Ethan,

Try this:

-- LeftMost bin:
SUM(DECODE(SIGN(lim_val0 - column_value),1,1,0,1,0))     -- less then
lim_val0

-- Middle bins:
SUM(DECODE(DECODE(SIGN(lim_val1 - column_value),-1,0,1), 1 ,
DECODE(SIGN(lim_val0 - column_value),-1,1,0), 0))     -- for
(lim_val1-lim_val0) bin
SUM(DECODE(DECODE(SIGN(lim_val2 - column_value),-1,0,1), 1 ,
DECODE(SIGN(lim_val1 - column_value),-1,1,0), 0))     -- for
(lim_val2-lim_val1) bin
SUM(DECODE(DECODE(SIGN(lim_val3 - column_value),-1,0,1), 1 ,
DECODE(SIGN(lim_val2 - column_value),-1,1,0), 0))     -- for
(lim_val3-lim_val2) bin
...................
.....................


-- RightMost bin:
SUM(DECODE(SIGN(lim_valN - column_value),1,0,0,0,1))     -- greater then
lim_valN



Igor Neyman, OCP DBA
Perceptron, Inc.
(734)414-4627
[EMAIL PROTECTED]


----- Original Message -----
To: "Multiple recipients of list ORACLE-L" <[EMAIL PROTECTED]>
Sent: Tuesday, July 24, 2001 1:28 PM


> Anyone got a good example of flipping a range of values into columner
> buckets.  I have done this in the past but my solutions always seem so
> convoluted, it seems I have seen more elegant examples in the past.  I
want
> to use decode so it will run on older versions of Oracle.
>
> Pseudo Example:
>
> select
>    sum(decode(if value between 0 and 64 then return 1 else 0))
> count_of_this_bucket,
>    sum(decode(if value between 65 and 128 then return 1 else 0))
> count_of_this_bucket,...
> from
>    table
>
> Thanks,
> Ethan
>
> --------------------------------------------------------------------------
----
> This e-mail is intended for the use of the addressee(s) only and may
contain privileged, confidential, or proprietary information that is exempt
from disclosure under law.  If you have received this message in error,
please inform us promptly by reply e-mail, then delete the e-mail and
destroy any printed copy.   Thank you.
>
>
============================================================================
==
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Post, Ethan
>   INET: [EMAIL PROTECTED]
>
> Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
> San Diego, California        -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from).  You may
> also send the HELP command for other information (like subscribing).

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Igor Neyman
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to