portableSql

IF Portable SQL Function

Syntax

If as A (Expression as L, TrueValue as A, FalseValue as A)

Arguments

ExpressionLogical

A logical expression that evaluates to a true or false value.

TrueValueAny Type

The value returned if the expression evaluates to true.

FalseValueAny Type

The value returned if the expression evaluates to false.

Returns

resultAny Type

Returns the TrueValue if the expression evaluates to true. Otherwise, returns the FalseValue.

Description

Evaluates a logical expression and returns the specified true or false value.

Discussion

The If function evaluates the logical Expression. If the expression evaluates to true, TrueValue is returned. Otherwise FalseValue is returned.

If() function executed on the Northwind Access database
SELECT FIRST 10 IF(ShippedDate IS NULL , 'Not shipped', 'Shipped') AS Shipped FROM Orders ORDER BY OrderID DESC
=Not shipped
Not shipped
Not shipped
Not shipped
Not shipped
Not shipped
Not shipped
Not shipped
Shipped
Not shipped