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 |
|
whiterabbot
Starting Member
18 Posts |
Posted - 2008-12-03 : 19:39:55
|
| My sqlQuery is,sqlQuery(dbconnection,"create view null_data2 as select TimeStamp FROM ScaledData_801 where CH1QUAL IS NOT NULL")a<-sqlQuery(dbconnection,"select ScaledData_801.CH1Avg as ws, ScaledData_801.TimeStamp from ScaledData_801,null_data2 where ScaledData_801.TimeStamp < = null_data2.TimeStamp+7 and ScaledData_801.TimeStamp > = null_data2.TimeStamp -7 and datepart(hh,ScaledData_801.TimeStamp) = datepart(hh,null_data2.TimeStamp)It does what I want but it is very slow. Does anyone have a more elegant solution>Thanks |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-12-03 : 19:57:54
|
| Maybe you just need this(Not sure)select CH1Avg , [TimeStamp] from [ScaledData_801] where [TimeStamp] between dateadd(dd,-7,[TimeStamp]) and dateadd(dd,7,[TimeStamp]) and CH1QUAL is not null |
 |
|
|
whiterabbot
Starting Member
18 Posts |
Posted - 2008-12-03 : 20:21:28
|
| Yes, I tired to use between before but my syntax was not right. Thank you. This is faster and more elegant.cheers and thanks for the fast reply. :) |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-12-03 : 21:18:17
|
Cool |
 |
|
|
|
|
|