Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Decode
This is not a CASE for decode ... it is a case for CASE. You are using the
wrong function.
If you are writing this in a procedure or function you will need to include it as native dynamic SQL.
Daniel Morgan
markag wrote:
> Oracle 8.1.5, Windows
>
> I need a decode SQL statement that will look at the difference between
> two dates and determine if they are GREATER THAN 13 weeks. If so, I
> count that row of data. I can do this with an equality test for each
> other week but cannot get it to work with greater Thans. i.e, this will
> count the records in the 'Week 13' bucket;
>
> SELECT DECODE (ROUND ( (SYSDATE - TRUNC (my_date)) / 7 + .5, 0),
> 13,COUNT (record_id), 0) w13 FROM cts GROUP BY TRUNC (my_date)
>
> ..
>
> I do saomething similar to this for each week bucket. I need a final
> bucket that is all inclusive of those > 13 weeks old.
>
> Don't really want to use variables to count the other buckets and
> subtract from a total count....
>
> TIA.
>
> --
> Posted via dBforums
> http://dbforums.com
Received on Tue Apr 02 2002 - 16:57:32 CST