Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Decode
Maybe its the lingering effects of the weekend's cold, but why don't you
select count(*)
from cts
where ( ROUND ( ( trunc( SYSDATE ) - TRUNC ( my_date ) ) / 7 + .5, 0 ) ) >
13;
??
"markag" <member_at_dbforums.com> wrote in message
news:3caa2e06$1_at_usenetgateway.com...
> 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 - 19:02:44 CST
![]() |
![]() |