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.
| Author |
Topic |
|
msugradus
Starting Member
40 Posts |
Posted - 2007-06-18 : 09:56:02
|
| I need to run a query that will automatically pull the sales for the last 30 and 90 days with out the user having to add any dates. Ideas? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-06-18 : 10:00:31
|
[code]select *from sales_tablewhere datecol >= dateadd(day, -30, getdate()) -- last 30 days[/code] KH |
 |
|
|
msugradus
Starting Member
40 Posts |
Posted - 2007-06-18 : 10:12:10
|
| ALTER PROCEDURE dbo.sp_Active_RepsAS select sum (case when OrderDate >= dateadd(day, -30, getdate()) then 1 else 0) as Month CountFROM exigo_data_sync.OrdersGet and ADO error, incorrect snytax line 3 near ')' ALTER PROCEDURE dbo.sp_Active_RepsAS select sum (case when OrderDate >= dateadd(day, -30, getdate()) then 1 else 0) as Month CountFROM exigo_data_sync.Orders |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-06-18 : 10:15:34
|
you missed out the end after the else before the )what are you trying to achieve here ? KH |
 |
|
|
msugradus
Starting Member
40 Posts |
Posted - 2007-06-18 : 10:22:43
|
| Thanks for the help. I am trying to create a query to build a report that will get the number of people that bought in the last 30 days and 90 days. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-20 : 06:05:52
|
| This would also workselect count(*)from sales_tablewhere datecol >= dateadd(day, -30, getdate()) -- last 30 daysMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|