Quote:
Originally Posted by n4nz
Hi,
I am trying to write a query to be used in view where I can obtain results on a daily basis without having to change the query this is what i have so far:
- SELECT BATCH_TYPE,
-
SUM(CASE WHEN RECEIVED_DATE BETWEEN TO_DATE('11-NOV-07 16:30:00', 'DD-MON-YY HH24:HH:MI:SS') AND TO_DATE('12-NOV-07 18:00:00' 'DD-MMM-YY HH24:HH:MI:SS')
-
FROM TABLE1
-
GROUP BY BATCH_TYPE
What i need to do is keep the same time intervals however keep the date as generic to 1 day in the past.
So for example where the Received Date is yesterday between 16:30 and Received Date is today and 18:00
The query is alot larger than the above example however if this part is resolved then the rest will fall into place. I don't want to have to edit the query daily.
Any help would be appreciated
The dates can be made generic using SYSDATES, but please clarify one thing, is it mandatory to use the time in the dates?
I would suggest to truncate the dates and then do the comparison in order to achieve better results.