Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Decode
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.comReceived on Tue Apr 02 2002 - 16:17:42 CST
![]() |
![]() |