Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Decode

Decode

From: markag <member_at_dbforums.com>
Date: 2 Apr 2002 22:17:42 GMT
Message-ID: <3caa2e06$1@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 - 16:17:42 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US