Solved

SQL filtering issue

Posted on 2014-09-26
3
386 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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

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