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
 Rolling10 days count

Author  Topic 

Petronas
Posting Yak Master

134 Posts

Posted - 2009-04-28 : 12:08:56
Hi All,

I have the below query:


select sale_code, count(*),sales_date
from Sales_Events (nolock)
where sales_id in ('AB02', 'CY02', 'NAB02')
group by sales_code,sales_date



What I want is the Rolling past 10 day count.
So if I run my query today I want to get the counts for the past 10 days.Using SQL server 2005

Thanks for your help,
Petronas

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-04-28 : 12:12:30
This?

select
sale_code
, count(*),sales_date
from
Sales_Events (nolock)
where
sales_id in ('AB02', 'CY02', 'NAB02')
AND sales_date >= DATEADD(DAY, -10, GETDATE())
group by
sales_code,sales_date



Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

Petronas
Posting Yak Master

134 Posts

Posted - 2009-04-28 : 12:19:23
Hi Transact Charlie,

I got the solution. Appreciate your help.

Thanks again,
Petronas
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-04-28 : 12:21:08
What was your solution?


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -