Knowledgebase
[QODBC-Desktop] How to use Case When statement query in QODBC
Posted by Rajendra Dewani (QODBC Support) on 14 April 2014 03:58 PM

Problem Description:

How can I use the Case When statement query in QODBC

Solution:

You can use the Case When statement query in QODBC as below:

The Simple CASE Statement is only used in the SELECT Statement to check whether the value is equal.

Below is an example:

SELECT ListID, Active = CASE IsActive WHEN 1 THEN 'Active' WHEN 0 THEN 'NotActive' ELSE 'UNKnown' END FROM Vendor

An example of a Case When with IN Statement:

You can use IN Statement in Case When as below.

For Example:

SELECT ListID, Balance, CASE WHEN Balance IN (11026.45,57938.60) THEN 'HIGH' WHEN Balance IN (2770.50,7125.50) THEN 'MED' WHEN Balance IN (0.45) THEN 'LOW' ELSE '--NA--' END FROM Vendor

(1 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please complete the captcha below (we use this to prevent automated submissions).