Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Trying to get the interval working

Author  Topic 

nosrekcid
Starting Member

1 Post

Posted - 2015-01-05 : 23:01:53
Hi,

I am brand new to SQL and am trying to write a script that will recur. It looks like:

SELECT SUM(Count(*)) AS "TOTAL"
FROM dcspp_order
WHERE created_by_order IS NOT NULL
AND BETWEEN next_day( trunc(SYSDATE) - interval '14' day, 'SUN')
AND next_day( trunc(SYSDATE) - interval '7' day, 'SAT')
GROUP BY Trunc(submitted_date);

I have one that works:

SELECT SUM(Count(*)) AS "TOTAL"
FROM dcspp_order
WHERE created_by_order IS NOT NULL
AND state != 'TEMPLATE'
AND (
Trunc(submitted_date) >= Trunc(SYSDATE-8))
AND (
Trunc(submitted_date) < Trunc(SYSDATE-1))
GROUP BY trunc(submitted_date);

I am trying to incorporate

WHERE <date col in question> BETWEEN next_day( trunc(sysdate) - interval '14' day, 'SUN') AND next_day( trunc(sysdate) - interval '7' day, 'SAT')

into the new script but it fails. Can anyone help me incorporate it?

Thanks,






Mike

"What if....."

robvolk
Most Valuable Yak

15732 Posts

Posted - 2015-01-06 : 07:02:04
SQLTeam.com is a Microsoft SQL Server site. For Oracle questions please visit http://dbforums.com/
Go to Top of Page
   

- Advertisement -