eo
MIS
- Apr 3, 2003
- 809
A simple formula shows some data for the past 14 days. You will see the date is hard coded:
select sum (FSA_Unearned) AS 'b/forward',
DateAdd (dd, 1, [Print Date]) as 'Print Date'
from dbo.CAT7EA
where [Print Date] = '2006-10-28'
group by [Print Date]
But hardcoding a date is far from ideal, so I tried:
select sum (FSA_Unearned) AS 'b/forward',
DateAdd (dd, 1, [Print Date]) as 'Print Date'
from dbo.CAT7EA
where [Print Date] >= DateAdd (dd, -14, [Print Date])
group by [Print Date]
The first formula returns the results within seconds, the second is pretty much non-responsive. Is this because the table is indexed by [Print Date] and a hard coded date means more to SQL than 14 days ago, which it will go and have to calculate (there is approx 60 million records in this table - hence the non-responsiveness)?
Any ideas?
EO
Hertfordshire, England
select sum (FSA_Unearned) AS 'b/forward',
DateAdd (dd, 1, [Print Date]) as 'Print Date'
from dbo.CAT7EA
where [Print Date] = '2006-10-28'
group by [Print Date]
But hardcoding a date is far from ideal, so I tried:
select sum (FSA_Unearned) AS 'b/forward',
DateAdd (dd, 1, [Print Date]) as 'Print Date'
from dbo.CAT7EA
where [Print Date] >= DateAdd (dd, -14, [Print Date])
group by [Print Date]
The first formula returns the results within seconds, the second is pretty much non-responsive. Is this because the table is indexed by [Print Date] and a hard coded date means more to SQL than 14 days ago, which it will go and have to calculate (there is approx 60 million records in this table - hence the non-responsiveness)?
Any ideas?
EO
Hertfordshire, England