System Functions
Reference of the SQL system functions supported by GridGain — CASEWHEN, CAST, COALESCE, CONVERT, DECODE, GREATEST, IFNULL, LEAST, NULLIF, NVL2, and TABLE.
CASEWHEN
Description
Returns 'aValue' if the Boolean expression is true, 'bValue' otherwise.
CASEWHEN (boolean , aValue , bValue)Parameters
boolean- the value to evaluateaValue- the value to return if Boolean istruebValue- value to return if Boolean isfalse
Example
Evaluate the ID and return the corresponding value:
CASEWHEN(ID=1, 'A', 'B')CAST
Description
Converts a value to another data type using one the following conversion rules:
When converting a number to a Boolean,
0 is consideredfalseand any other value is consideredtrue`When converting a Boolean to a number,
falseis0andtrueis1When converting a number to a number of another type, the value is checked for overflow
When converting a number to a binary type, the number of bytes matches the precision
When converting a string to a binary type, it is hex-encoded
A hex string can be converted to the binary type and then to a number; if a direct conversion is not possible, the value is first converted to a string
Parameters
value- the value to convertdataType- the data type to convert the value to
Examples
COALESCE | NVL
Description
Returns the first value that is not NULL.
Parameters
aValue, bValue - values to process
Example
Return the first non-null value out of A, B, and C:
CONVERT
Description
Converts a value to another data type.
Parameters
value- the value to convertdataType- the data type to convert the value to
Example
Convert NAME to an integer:
DECODE
Description
Returns the first matching value. NULL matches NULL. If no match is found, NULL or the last parameter is returned (if the parameter count is even).
Parameters
value- the value to match againstwhenValue,thenValue, etc. - values to check
Example
Return the first value that matches random number greater than 0.5:
GREATEST
Description
Returns the greatest value that is not NULL, or NULL if all values are NULL.
Parameters
aValue, bValue - values to process
Example
Return the greatest values out of 1, 2, and 3:
IFNULL
Description
Returns 'a' if the value is not NULL, 'b' otherwise.
Parameters
aValue, bValue - values to process
Example
Check NULL and space ('') for being NULL:
LEAST
Description
Returns the smallest value that is not NULL, or NULL if all values are NULL.
Parameters
Example
NULLIF
Description
Returns NULL if 'a' equals 'b', otherwise returns 'a'.
Parameters
aValue, bValue - values to process
Example
Check if A=B:
NVL2
Description
If the test value is NULL, returns 'bValue'. Otherwise, returns 'aValue'. The data type of the returned value is the same as that of 'aValue'.
Parameters
testValue- the value to test forNULLaValue- the value to return if testVale is notNULLbValue- the value to return if testVale isNULL
Example
Test if X is NULL:
TABLE | TABLE_DISTINCT
Description
Returns the result set that matches the criteria. TABLE_DISTINCT removes duplicate rows.
Parameters
name- the table namedataType- the data type to returnexpression- the expression that defines the dataType
Example
Return everything from the table:
This page is: Copyright © 2026 MariaDB. All rights reserved.
Last updated
Was this helpful?

