Skip to main content

Numeric Functions

FunctionDescription
ABS(n)Absolute value
CEILING(n)Smallest integer >= n
FLOOR(n)Largest integer <= n
ROUND(n, d)Round n to d decimal places
TRUNCATE(n, d)Truncate n to d decimal places
SELECT ABS(-42)            -- 42
SELECT CEILING(4.1)        -- 5
SELECT FLOOR(4.9)          -- 4
SELECT ROUND(3.14159, 2)   -- 3.14
SELECT TRUNCATE(3.99, 1)   -- 3.9

String Functions

FunctionDescription
ASCII(s)ASCII code of the first character
CHAR(n)Character for ASCII code n
CONCAT(s1, s2, ...)Concatenate strings (NULLs treated as empty)
CONCAT_WS(sep, s1, s2, ...)Concatenate with separator, skipping NULLs
INSTR(s, sub)Position of first occurrence of sub in s (1-based)
LEFT(s, n)First n characters
LENGTH(s)Length in characters
LOWER(s)Convert to lowercase
LPAD(s, n, pad)Left-pad s to length n with pad string
LTRIM(s)Remove leading whitespace
RIGHT(s, n)Last n characters
RPAD(s, n, pad)Right-pad s to length n with pad string
RTRIM(s)Remove trailing whitespace
SUBSTRING(s, pos, len)Extract substring (1-based position)
TRIM(s)Remove leading and trailing whitespace
UPPER(s)Convert to uppercase
SELECT UPPER(name) AS name_upper FROM myschema.users
SELECT CONCAT_WS(', ', last_name, first_name) AS full_name FROM myschema.contacts
SELECT SUBSTRING(sku, 1, 3) AS sku_prefix FROM myschema.products
SELECT LPAD(order_number, 8, '0') AS padded FROM myschema.orders
SELECT LENGTH(description) AS desc_length FROM myschema.products

Conditional Functions

IF(condition, true_value, false_value) — returns true_value when condition is truthy, otherwise false_value:
SELECT
  id,
  IF(total > 500, 'high_value', 'standard') AS tier
FROM myschema.orders

UUID

Generate a random UUID v4:
SELECT UUID() AS request_id

Date/Time Functions

FunctionDescription
CURRENT_DATE()Current date as YYYY-MM-DD
CURRENT_TIMESTAMP()Current date and time as a string
SELECT CURRENT_DATE()       -- e.g. '2026-03-11'
SELECT CURRENT_TIMESTAMP()  -- e.g. 'Tue Mar 11 2026 17:00:00 GMT+0000'
These return strings, not native date objects. To compare against stored date strings, use standard string comparison operators.

Aggregate Functions

FunctionDescription
COUNT(*)Count all rows
COUNT(col)Count non-NULL values
SUM(col)Sum of non-NULL values
AVG(col)Average of non-NULL values
MIN(col)Minimum value
MAX(col)Maximum value
STDDEV(col)Population standard deviation
See Grouping and Aggregation for usage with GROUP BY and HAVING.

Not Supported

  • EXTRACT, DATE_ADD, DATE_DIFF, DATEDIFF, NOW()
  • CONVERT / CAST