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: 3 Apr 2002 16:12:28 GMT
Message-ID: <3cab29ec$1@usenetgateway.com>


Hi,

I have a report I am writing that does a count of records based on a date range, broken down by week. For example,

SELECT SUM (w1) FROM (SELECT DECODE (ROUND ( (SYSDATE - TRUNC (my_date)) / 7 + .5, 0), 1, COUNT (ctsid), 0.00) w1 FROM cts GROUP BY TRUNC (my_date))

would roll up the count for all records with a my_date value within 1 week of the current date. I got this working for weeks 1-13. I now need to do it for all counts OVER the 13th week. I really do not want to keep running counts of the first 13 weeks then deduct it from the total. I'd like it to be right inside this SQL statement.

TIA.

--
Posted via dBforums
http://dbforums.com
Received on Wed Apr 03 2002 - 10:12:28 CST

Original text of this message

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