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 |
|
rds207
Posting Yak Master
198 Posts |
Posted - 2009-08-11 : 14:33:34
|
| I HAVE A QUERY---select ApplicationName,Site,SubmitTime,StartTime ,EndTime,DATEDIFF(SECOND,StartTime,SubmitTime) as QueueTimeSecs,DATEDIFF(MINUTE,StartTime,EndTime) as RunnableTime_Minutes from ASWProductionDatabase.dbo.BatchRecords where Site like 'SANDIEGO'AND Year(StartTime) = 2009 AND ApplicationName like'eng%' or ApplicationName like'buildph%'or ApplicationName LIKE'ENG %'or ApplicationName like'patchbuild'or ApplicationName like'SANBATCH'or ApplicationName like'Requestph'order by StartTime-------------------------------------------SO I AM GETTING THE RESULTS OF DIFFERENT SITE NAMES TO FOR EG SITE:NEWJERSEY ..ETChOW DO I USE HAVING CLAUSE FOR MULTIPLE VALUSE OR CAN I USE LIKE FOR MULTIPLE VALUES??I NEED TO GET THE ROWS WHERE THE APPLICATION NAME IS SANBATCH,PATCHBUILD ETC BUT THE SITE SHOULD BE SAN DIEGO.... |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2009-08-11 : 16:47:02
|
You have a logic issue. Try placing parenthesis aroud the OR clauses.quote: Originally posted by rds207 I HAVE A QUERY---select ApplicationName,Site,SubmitTime,StartTime ,EndTime,DATEDIFF(SECOND,StartTime,SubmitTime) as QueueTimeSecs,DATEDIFF(MINUTE,StartTime,EndTime) as RunnableTime_Minutes from ASWProductionDatabase.dbo.BatchRecords where Site like 'SANDIEGO'AND Year(StartTime) = 2009 AND (ApplicationName like'eng%' or ApplicationName like'buildph%'or ApplicationName LIKE'ENG %'or ApplicationName like'patchbuild'or ApplicationName like'SANBATCH'or ApplicationName like'Requestph')order by StartTime-------------------------------------------SO I AM GETTING THE RESULTS OF DIFFERENT SITE NAMES TO FOR EG SITE:NEWJERSEY ..ETChOW DO I USE HAVING CLAUSE FOR MULTIPLE VALUSE OR CAN I USE LIKE FOR MULTIPLE VALUES??I NEED TO GET THE ROWS WHERE THE APPLICATION NAME IS SANBATCH,PATCHBUILD ETC BUT THE SITE SHOULD BE SAN DIEGO....
Also you should change your check for the YEAR to soemthing sargable.. like:StartTime >= '20090101'AND StartTime < 20100101' |
 |
|
|
rds207
Posting Yak Master
198 Posts |
Posted - 2009-08-11 : 17:28:39
|
| THANK YOU! |
 |
|
|
|
|
|
|
|