Solved

SQL filtering issue

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TSQL DateADD update Question 4 30
Sql Join Problem 2 33
SQL Query with WHERE clause for an entire day 5 20
ebay table structure 2 14
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now