> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamosql.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Functions

> Built-in numeric, string, conditional, and aggregate functions.

## Numeric Functions

| Function         | Description                    |
| ---------------- | ------------------------------ |
| `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 |

```sql theme={null}
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

| Function                      | Description                                        |
| ----------------------------- | -------------------------------------------------- |
| `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                               |

```sql theme={null}
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`:

```sql theme={null}
SELECT
  id,
  IF(total > 500, 'high_value', 'standard') AS tier
FROM myschema.orders
```

## UUID

Generate a random UUID v4:

```sql theme={null}
SELECT UUID() AS request_id
```

## Date/Time Functions

| Function              | Description                       |
| --------------------- | --------------------------------- |
| `CURRENT_DATE()`      | Current date as `YYYY-MM-DD`      |
| `CURRENT_TIMESTAMP()` | Current date and time as a string |

```sql theme={null}
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

| Function      | Description                   |
| ------------- | ----------------------------- |
| `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](/sql-reference/grouping-and-aggregation) for usage with `GROUP BY` and `HAVING`.

## Not Supported

* `EXTRACT`, `DATE_ADD`, `DATE_DIFF`, `DATEDIFF`, `NOW()`
* `CONVERT` / `CAST`
