Add truncate and trunc functions usage

This commit is contained in:
peter279k 2024-04-12 19:47:38 +08:00
parent d613a1d623
commit 2d6c51578a
No known key found for this signature in database
GPG Key ID: 4F0DC51B27994EFE

View File

@ -26,6 +26,37 @@ Returns the smallest round number that is greater than or equal to `x`. In every
Returns the round number with largest absolute value that has an absolute value less than or equal to `x`s. In every other way, it is the same as the floor function (see above).
**Syntax**
```sql
trunc(input, precision)
```
Alias: `truncate`.
**Parameters**
- `input`: A float type [Float](/docs/en/sql-reference/data-types/float.md).
- `precision`: A decimal type [Decimal](/docs/en/sql-reference/data-types/decimal.md).
**Returned value**
- A [Float64](/docs/en/sql-reference/data-types/float.md) value.
**Example**
Query:
```sql
SELECT trunc(123.45, 1) as res;
```
```response
┌───res─┐
│ 123.4 │
└───────┘
```
## round(x\[, N\])
Rounds a value to a specified number of decimal places.