Solved

If in Where Clause for SQL Query

Posted on 2008-10-23
2
366 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
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Query Syntax Join 4 39
Extract string portion 2 24
SQL Result Set to XML 4 36
Why i am getting a star, SSMS does not show me any error. Division Error 5 22
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
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.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

773 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