Kbase P133106: SQL: How to select an expression based on the value of a logical (boolean) field?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  09/07/2008 |
|
Status: Unverified
GOAL:
SQL: How to select an expression based on the value of a logical (boolean) field?
GOAL:
Sample SELECT statement using the SQL CASE function?
FACT(s) (Environment):
All Supported Operating Systems
Progress 9.x
OpenEdge 10.x
FIX:
Use the SQL CASE function. For example, the following CASE function selects the value of the "Balance" column for the rows where the "Logical-Field" column is true, the value of the "CreditLimit" column for the rows where the "Logical-Field" is false and the value NULL for the rows where the "Logical-Field" is unknown:
SELECT
CASE
WHEN "Logical-Field" = 1 THEN Balance
WHEN "Logical-Field" = 0 THEN CreditLimit
ELSE NULL
END
AS OutColumn
FROM
pub.Customer