Solved

SQL filtering issue

Posted on 2014-09-26
3
385 Views
Last Modified: 2014-09-26
My WHERE clause in my query must have faulty logic.

WHERE (rems.project.hidden = 0) AND (NOT (rems.jobsalesexti.prodcode IN ('0000Base', 'ELEVA', 'ELEVB', 'ELEVC', 'EXTCOL'))) AND (rems.jobsalesexts.paycode = '') OR
               (rems.jobsalesexts.paycode = 'Draw 1')

Open in new window


The second part of my filter works but the first part is ignored. Is there a way to structure this so that I can get the desired result?
0
Comment
Question by:J C
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 500 total points
ID: 40346349
If your desire is not to bring back all paycodes equal to Draw 1, then place parentheses around the two paycode filters:
AND ((rems.jobsalesexts.paycode = '') OR (rems.jobsalesexts.paycode = 'Draw 1'))
0
 

Author Comment

by:J C
ID: 40346403
Right now the issue is that the filter expression with the OR operator is working but the prodcode IN () is being ignored. Do you see any reason why the filter expression as a whole would not work?
0
 

Author Comment

by:J C
ID: 40346432
I'm sorry...You're solution did resolve my problem. Thank you!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Applying Roles in Common Scenarios 3 19
SQL Convert "vertical" data to "horizontal" data 4 30
SQL Help 4 16
Neglected Questions 3 12
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question