Solved

If in Where Clause for SQL Query

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sql Stored Procedure field variable 17 38
SQL Server: Unable to remove duplicate sets in Header/Detail 6 27
average of calculation (TSQL) 4 26
SQL query and VBA 5 46
As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

830 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