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 |
Nlara
Starting Member
2 Posts |
Posted - 2014-11-06 : 09:33:53
|
Hello,First time post here and also a newbie..I am trying to filter my columns on multiple values. I need them all to be OR because I want it to look through all of the columns and wherever the value matches to not include in the view. My WHERE clause that I thought would work looked like this..WHERE (NOT (RTPL_VOLUME_DATA_1.SYMBOL LIKE '%spot%')) AND (NOT (RTPL_VOLUME_DATA_1.ISSPREAD = 'True')) AND (NOT (RTPL_VOLUME_DATA_1.GMIPRODUCTCODE = 'Internal')) AND (RTPL_VOLUME_DATA_1.TAG_COMMENT IN ('[]', '[Gscalp]', '[TT]', '[GX2]', '[NA]', '[STELLAR]')) OR (RTPL_VOLUME_DATA_1.TAG_COMMENT IS NULL)However this does not work and provide the data needed. I then thought that if I replaced all the AND's with OR's that would work, but here it does not filter anything.. not sure where to go from here. |
|
mandm
Posting Yak Master
120 Posts |
Posted - 2014-11-06 : 09:57:14
|
I'm guessing that your TAG_COMMENT column is NULL and since it is all alone with the OR it is using that instead of your other filter logic. How should that check relate to the rest of your filter? |
|
|
Nlara
Starting Member
2 Posts |
Posted - 2014-11-06 : 11:55:41
|
So I found out that it was a matter of Parenthesis. They needed to be placed in the last clause so it looks like this.WHERE (NOT (RTPL_VOLUME_DATA_1.SYMBOL LIKE '%spot%')) AND (NOT (RTPL_VOLUME_DATA_1.ISSPREAD = 'True')) AND (NOT (RTPL_VOLUME_DATA_1.GMIPRODUCTCODE = 'Internal')) AND ( (RTPL_VOLUME_DATA_1.TAG_COMMENT IN ('[]', '[Gscalp]', '[TT]', '[GX2]', '[NA]', '[STELLAR]')) OR(RTPL_VOLUME_DATA_1.TAG_COMMENT IS NULL)) |
|
|
mandm
Posting Yak Master
120 Posts |
Posted - 2014-11-07 : 08:17:23
|
Glad that you found your answer. |
|
|
|
|
|
|
|