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 |
|
cwestern
Starting Member
7 Posts |
Posted - 2012-06-01 : 12:03:15
|
Can someone help me format this WHERE statement. I'm not sure if I'm using the brackets correctly and have the statement in correct order. Any Help would be amazing....WHERE ( ( ( TransactionDate BETWEEN @YesterdayDateHourMinuteSecond AND @TodayDateHourMinuteSecond ) AND ( h.TransactionType LIKE '%SCR%' ) AND ( ( TransactionDate BETWEEN @YesterdayDateHourMinuteSecond AND @TodayDateHourMinuteSecond ) OR ( h.TransactionType LIKE '%SCP%' ) |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-01 : 12:07:07
|
we're not sure on your requirement. but anyways it looks like this what you're after. If not, post some sample data and explain how you want to filter out of themWHERE ( ( TransactionDate BETWEEN @YesterdayDateHourMinuteSecond AND @TodayDateHourMinuteSecond ) AND ( h.TransactionType LIKE '%SCR%' OR h.TransactionType LIKE '%SCP%' ) ) ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2012-06-01 : 12:43:36
|
Just ripping off what Visakh did and tweak it a little bit:WHERE TransactionDate BETWEEN @YesterdayDateHourMinuteSecond AND @TodayDateHourMinuteSecond AND h.TransactionType LIKE '%SC[RP]%' |
 |
|
|
cwestern
Starting Member
7 Posts |
Posted - 2012-06-01 : 13:06:20
|
| Thank you guys so much. I didn't know you could do the LIKE %SC[RP]% |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-01 : 23:38:50
|
| wc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|