Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Decode
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.comReceived on Wed Apr 03 2002 - 10:12:28 CST
![]() |
![]() |