DECODE
Examples
select name,
age,
decode(upper(sex),
'M', 'Male',
'F', 'Female',
'Unknown'),
religion
from people
Functions for Sequences (Generators)
DECODE
Examplesselect name,
age,
decode(upper(sex),
'M', 'Male',
'F', 'Female',
'Unknown'),
religion
from people
IIF()
Ternary conditional function
Depends on input
IIF (<condition>, ResultT, ResultF)
Parameter | Description |
---|---|
condition |
A true|false expression |
resultT |
The value returned if the condition is true |
resultF |
The value returned if the condition is false |
IIF
takes three arguments.If the first evaluates to true
, the second argument is returned;otherwise the third is returned.
IIF
could be likened to the ternary “<condition> ? resultT : resultF
” operator in C-like languages.
Note
|
|
IIF
Examplesselect iif( sex = 'M', 'Sir', 'Madam' ) from Customers
MAXVALUE()
Returns the maximum value of its arguments
Varies according to input — result will be of the same data type as the first expression in the list (expr1).
MAXVALUE (<expr1> [, ... , <exprN> ])
Parameter | Description |
---|---|
expr1 … exprN |
List of expressions of compatible types |
Returns the maximum value from a list of numerical, string, or date/time expressions.This function fully supports text BLOB
s of any length and character set.
If one or more expressions resolve to NULL
, MAXVALUE
returns NULL
.This behaviour differs from the aggregate function MAX
.
MAXVALUE
ExamplesSELECT MAXVALUE(PRICE_1, PRICE_2) AS PRICE
FROM PRICELIST
MINVALUE()
Returns the minimum value of its arguments
Varies according to input — result will be of the same data type as the first expression in the list (expr1).
MINVALUE (<expr1> [, ... , <exprN> ])
Parameter | Description |
---|---|
expr1 … exprN |
List of expressions of compatible types |
Returns the minimum value from a list of numerical, string, or date/time expressions.This function fully supports text BLOB
s of any length and character set.
If one or more expressions resolve to NULL
, MINVALUE
returns NULL
.This behaviour differs from the aggregate function MIN
.
MINVALUE
ExamplesSELECT MINVALUE(PRICE_1, PRICE_2) AS PRICE
FROM PRICELIST
NULLIF()
Conditional NULL
function
Depends on input
NULLIF (<exp1>, <exp2>)
Parameter | Description |
---|---|
exp1 |
An expression |
exp2 |
Another expression of a data type compatible with exp1 |
NULLIF
returns the value of the first argument, unless it is equal to the second.In that case, NULL
is returned.
NULLIF
Exampleselect avg( nullif(Weight, -1) ) from FatPeople
This will return the average weight of the persons listed in FatPeople, excluding those having a weight of -1, since AVG
skips NULL
data.Presumably, -1 indicates “weight unknown” in this table.A plain AVG(Weight)
would include the -1 weights, thus skewing the result.