TO_BASE
All functions > MATH > TO_BASE
Converts a decimal number to a specified base representation.
Syntax
TO_BASE(expr, base)
sql
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
decimal_number | BIGINT | Yes | The decimal (base 10) number to convert |
base | BIGINT | Yes | The target base (2-36) |
Returns
VARCHAR - String representation in the target base
Notes
- Supports bases from 2 (binary) to 36
- For bases > 10, uses letters A-Z for digits 10-35
- Returns uppercase letters for bases > 10
- Returns NULL if decimal_number is NULL
- Useful for converting to binary, octal, hexadecimal