Functions
Arneb provides 19 built-in scalar functions organized by category.
String Functions
UPPER
Converts a string to uppercase.
UPPER(string) → VARCHARSELECT UPPER('hello'); -- 'HELLO'LOWER
Converts a string to lowercase.
LOWER(string) → VARCHARSELECT LOWER('HELLO'); -- 'hello'SUBSTRING
Extracts a substring starting at a given position with an optional length.
SUBSTRING(string FROM start [FOR length]) → VARCHARSELECT SUBSTRING('Hello World' FROM 1 FOR 5); -- 'Hello'
SELECT SUBSTRING('Hello World' FROM 7); -- 'World'TRIM
Removes leading and trailing whitespace (or specified characters) from a string.
TRIM([LEADING | TRAILING | BOTH] [characters FROM] string) → VARCHARSELECT TRIM(' hello '); -- 'hello'
SELECT TRIM(LEADING ' ' FROM ' hello '); -- 'hello 'LTRIM
Removes leading whitespace from a string.
LTRIM(string) → VARCHARSELECT LTRIM(' hello'); -- 'hello'RTRIM
Removes trailing whitespace from a string.
RTRIM(string) → VARCHARSELECT RTRIM('hello '); -- 'hello'CONCAT
Concatenates two or more strings.
CONCAT(string1, string2, ...) → VARCHARSELECT CONCAT('Hello', ' ', 'World'); -- 'Hello World'LENGTH
Returns the number of characters in a string.
LENGTH(string) → INTEGERSELECT LENGTH('hello'); -- 5REPLACE
Replaces all occurrences of a substring within a string.
REPLACE(string, from, to) → VARCHARSELECT REPLACE('hello world', 'world', 'there'); -- 'hello there'POSITION
Returns the position of a substring within a string (1-based).
POSITION(substring IN string) → INTEGERSELECT POSITION('world' IN 'hello world'); -- 7Math Functions
ABS
Returns the absolute value of a number.
ABS(number) → NUMBERSELECT ABS(-42); -- 42ROUND
Rounds a number to a specified number of decimal places.
ROUND(number [, decimal_places]) → NUMBERSELECT ROUND(3.14159, 2); -- 3.14
SELECT ROUND(3.5); -- 4CEIL
Returns the smallest integer greater than or equal to the argument.
CEIL(number) → INTEGERSELECT CEIL(3.2); -- 4
SELECT CEIL(-3.2); -- -3FLOOR
Returns the largest integer less than or equal to the argument.
FLOOR(number) → INTEGERSELECT FLOOR(3.8); -- 3
SELECT FLOOR(-3.2); -- -4MOD
Returns the remainder of a division.
MOD(dividend, divisor) → NUMBERSELECT MOD(10, 3); -- 1POWER
Returns a number raised to a power.
POWER(base, exponent) → NUMBERSELECT POWER(2, 10); -- 1024Date Functions
EXTRACT
Extracts a field from a date or timestamp.
EXTRACT(field FROM source) → INTEGERSupported fields: YEAR, MONTH, DAY, HOUR, MINUTE, SECOND.
SELECT EXTRACT(YEAR FROM DATE '2024-06-15'); -- 2024
SELECT EXTRACT(MONTH FROM DATE '2024-06-15'); -- 6CURRENT_DATE
Returns the current date.
CURRENT_DATE → DATESELECT CURRENT_DATE; -- 2024-06-15DATE_TRUNC
Truncates a date or timestamp to the specified precision.
DATE_TRUNC('precision', source) → DATE/TIMESTAMPSupported precisions: year, month, day, hour, minute, second.
SELECT DATE_TRUNC('month', DATE '2024-06-15'); -- 2024-06-01
SELECT DATE_TRUNC('year', DATE '2024-06-15'); -- 2024-01-01