Solved

If in Where Clause for SQL Query

Posted on 2008-10-23
2
363 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
2 Comments
 
LVL 9

Accepted Solution

by:
jamesgu earned 500 total points
Comment Utility
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
Comment Utility
Thanks!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

19 Experts available now in Live!

Get 1:1 Help Now