Solved

If in Where Clause for SQL Query

Posted on 2008-10-23
2
368 Views
Last Modified: 2012-05-05
What is the correct syntax for using an IF in a WHERE clause? I need something like


Where IF (A, B='PO', C='OS')

In this example "A" is a logical
B is an Order Type
C is a Status)
0
Comment
Question by:sfletcher1959
[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 Comments
 
LVL 9

Accepted Solution

by:
jamesgu earned 500 total points
ID: 22789116
what do you exactly by Where IF (A, B='PO', C='OS')? something like if A is true ues the condition b='PO', otherwise use c='OS'.

If this is what you wanted, use this

where ( condition_a  and B='PO') or (not condition_a  and C='OS')

please give more information
0
 

Author Closing Comment

by:sfletcher1959
ID: 31509340
Thanks!
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
compare date to getdate() 8 34
Populating a table from inside a trigger 2 15
Query Task 8 20
SQL join ...want to return one row 4 14
In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 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