Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 127 additions & 21 deletions docs/querying/sql-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -1069,11 +1069,30 @@ Returns the following:

## LOG10

`LOG10(expr)`
Calculates the base-10 logarithm of the numeric expression.

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
* **Syntax:** `LOG10(<NUMERIC>)`
* **Function type:** Scalar, numeric

<details><summary>Example</summary>

Calculates the base-10 of the numeric expression.
The following example applies the LOG10 function to the `max_temperature` column from the `taxi-trips` datasource.

```sql
SELECT
"max_temperature" AS "max_temperature",
LOG10("max_temperature") AS "log10_max_temp"
FROM "taxi-trips"
LIMIT 1
```
Returns the following:

| `max_temperature` | `log10_max_temp` |
| -- | -- |
| `76` | `1.8808135922807914` |
</details>

[Learn more](sql-scalar.md#numeric-functions)

## LOOKUP

Expand Down Expand Up @@ -1133,11 +1152,26 @@ Returns the minimum value of a set of values.

## MOD

`MOD(x, y)`
Calculates x modulo y, or the remainder of x divided by y. Where x and y are numeric expressions.

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
* **Syntax:** `MOD(x, y)`
* **Function type:** Scalar, numeric

<details><summary>Example</summary>

The following calculates 78 MOD 10.

```sql
SELECT MOD(78, 10) as "modulo"
```
Returns the following:

| `modulo` |
| -- |
| `8` |
</details>

Calculates x modulo y, or the remainder of x divided by y.
[Learn more](sql-scalar.md#numeric-functions)

## MV_APPEND

Expand Down Expand Up @@ -1317,11 +1351,26 @@ Returns the one-based index position of a substring within an expression, option

## POWER

`POWER(expr, power)`
Calculates a numerical expression raised to the specified power.

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
* **Syntax:** `POWER(base, exponent)`
* **Function type:** Scalar, numeric

Calculates a numerical expression raised to the specified power.
<details><summary>Example</summary>

The following example raises 5 to the power of 2.

```sql
SELECT POWER(5, 2) AS "power"
```
Returns the following:

| `power` |
| -- |
| `25` |
</details>

[Learn more](sql-scalar.md#numeric-functions)

## RADIANS

Expand Down Expand Up @@ -1398,11 +1447,31 @@ Returns the rightmost number of characters from an expression.

## ROUND

`ROUND(expr[, digits])`
Calculates the rounded value for a numerical expression.

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
* **Syntax:** `ROUND(expr[, digits])`
* **Function type:** Scalar, numeric

Calculates the rounded value for a numerical expression.
<details><summary>Example</summary>

The following applies the ROUND function to 0 decimal points on the `pickup_longitude` column from the `taxi-trips` datasource.

```sql
SELECT
"pickup_longitude" AS "pickup_longitude",
ROUND("pickup_longitude", 0) as "rounded_pickup_longitude"
FROM "taxi-trips"
WHERE "pickup_longitude" IS NOT NULL
LIMIT 1
```
Returns the following:

| `pickup_longitude` | `rounded_pickup_longitude` |
| -- | -- |
| `-73.9377670288086` | `-74` |
</details>

[Learn more](sql-scalar.md#numeric-functions)

## ROW_NUMBER

Expand Down Expand Up @@ -1446,11 +1515,26 @@ Calculates the trigonometric sine of an angle expressed in radians.

## SQRT

`SQRT(expr)`
Calculates the square root of a numeric expression.

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
* **Syntax:** `SQRT(<NUMERIC>)`
* **Function type:** Scalar, numeric

Calculates the square root of a numeric expression.
<details><summary>Example</summary>

The following example calculates the square root of 25.

```sql
SELECT SQRT(25) AS "square_root"
```
Returns the following:

| `square_root` |
| -- |
| `5` |
</details>

[Learn more](sql-scalar.md#numeric-functions)

## STDDEV

Expand Down Expand Up @@ -1720,20 +1804,41 @@ Trims the leading or trailing characters of an expression.

## TRUNC

`TRUNC(expr[, digits])`
Alias for [`TRUNCATE`](#truncate).

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
* **Syntax:** `TRUNC(expr[, digits])`
* **Function type:** Scalar, numeric

Alias for [`TRUNCATE`](#truncate).
[Learn more](sql-scalar.md#numeric-functions)

## TRUNCATE

`TRUNCATE(expr[, digits])`
Truncates a numerical expression to a specific number of decimal digits.

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
* **Syntax:** `TRUNCATE(expr[, digits])`
* **Function type:** Scalar, numeric

Truncates a numerical expression to a specific number of decimal digits.
<details><summary>Example</summary>

The following applies the TRUNCATE function to 1 decimal place on the `pickup_longitude` column from the `taxi-trips` datasource.

```sql
SELECT
"pickup_longitude" as "pickup_longitude",
TRUNCATE("pickup_longitude", 1) as "truncate_pickup_longitude"
FROM "taxi-trips"
WHERE "pickup_longitude" IS NOT NULL
LIMIT 1
```
Returns the following:

| `pickup_longitude` | `truncate_pickup_longitude` |
| -- | -- |
| `-73.9377670288086` | `-73.9` |
</details>


[Learn more](sql-scalar.md#numeric-functions)

## TRY_PARSE_JSON

Expand Down Expand Up @@ -1783,3 +1888,4 @@ Calculates the sample variance of a set of values.

Alias for [`VAR_SAMP`](#var_samp).