Skip to content

Commit

Permalink
batch 03 - trig functions
Browse files Browse the repository at this point in the history
  • Loading branch information
edgar2020 committed Jul 24, 2024
1 parent 02b8738 commit ca475a1
Showing 1 changed file with 180 additions and 30 deletions.
210 changes: 180 additions & 30 deletions docs/querying/sql-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,26 @@ Returns the following:

## ACOS

`ACOS(<NUMERIC>)`
Calculates the arc cosine of a numeric expression.

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

Calculates the arc cosine of a numeric expression.
<details><summary>Example</summary>

The following example calculates the arc cosine of zero.

```sql
SELECT ACOS(0) AS "arc_cosine"
```
Returns the following:

| `arc_tangent` |
| -- |
| `1.5707963267948966` |
</details>

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

## ANY_VALUE

Expand Down Expand Up @@ -280,27 +295,72 @@ Joins all elements of `arr` by the delimiter specified by `str`.

## ASIN

`ASIN(<NUMERIC>)`
Calculates the arc sine of a numeric expression.

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

Calculates the arc sine of a numeric expression.
<details><summary>Example</summary>

## ATAN
The following example calculates the arc sine of one.

`ATAN(<NUMERIC>)`
```sql
SELECT ASIN(1) AS "arc_sine"
```
Returns the following:

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
| `arc_sine` |
| -- |
| `1.5707963267948966` |
</details>

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

## ATAN

Calculates the arc tangent of a numeric expression.

* **Syntax:** `ATAN(expr)`
* **Function type:** Scalar, numeric

<details><summary>Example</summary>

The following example calculates the arc tangent of one.

```sql
SELECT ATAN(1) AS "arc_tangent"
```
Returns the following:

| `arc_tangent` |
| -- |
| `0.7853981633974483` |
</details>

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

## ATAN2

`ATAN2(<NUMERIC>, <NUMERIC>)`
Calculates the arc tangent of specified x and y coordinates.

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

<details><summary>Example</summary>

The following example calculates the arc tangent of the coordinate (1, -1)

```sql
SELECT ATAN2(1,-1) AS "arc_tangent_2"
```
Returns the following:

| `arc_tangent` |
| -- |
| `2.356194490192345` |
</details>

Calculates the arc tangent of the two arguments.
[Learn more](sql-scalar.md#numeric-functions)

## AVG

Expand Down Expand Up @@ -514,20 +574,50 @@ Finds whether a string is in a given expression, case-sensitive.

## COS

`COS(<NUMERIC>)`
Calculates the trigonometric cosine of an angle expressed in radians.

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

Calculates the trigonometric cosine of an angle expressed in radians.
<details><summary>Example</summary>

## COT
The following example calculates the cosine of `PI` over three radians.

`COT(<NUMERIC>)`
```sql
SELECT COS(PI / 3) AS "cosine"
```
Returns the following:

**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions)
| `COS` |
| -- |
| `0.5000000000000001` |
</details>

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

## COT

Calculates the trigonometric cotangent of an angle expressed in radians.

* **Syntax:** `COT(expr)`
* **Function type:** Scalar, numeric

<details><summary>Example</summary>

The following example calculates the cotangent of `PI` over three radians.

```sql
SELECT COT(PI / 3) AS "cotangent"
```
Returns the following:

| `cotangent` |
| -- |
| `0.577350269189626` |
</details>

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

## COUNT

`COUNT([DISTINCT] expr)`
Expand Down Expand Up @@ -589,11 +679,26 @@ Decodes a Base64-encoded string into a UTF-8 encoded string.

## DEGREES

`DEGREES(<NUMERIC>)`
Converts an angle from radians to degrees.

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

Converts an angle from radians to degrees.
<details><summary>Example</summary>

The following example converts `PI` radians to degrees

```sql
SELECT DEGREES(PI) AS "degrees"
```
Returns the following:

| `degrees` |
| -- |
| `180` |
</details>

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

## DENSE_RANK

Expand Down Expand Up @@ -1325,11 +1430,26 @@ Calculates a numerical expression raised to the specified power.

## RADIANS

`RADIANS(expr)`
Converts an angle from degrees to radians.

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

Converts an angle from degrees to radians.
<details><summary>Example</summary>

The following example converts 180 degrees to radians

```sql
SELECT RADIANS(180) AS "radians"
```
Returns the following:

| `radians` |
| -- |
| `3.141592653589793` |
</details>

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

## RANK

Expand Down Expand Up @@ -1438,11 +1558,26 @@ Returns `x` divided by `y`, guarded on division by 0.

## SIN

`SIN(expr)`
Calculates the trigonometric sine of an angle expressed in radians.

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

Calculates the trigonometric sine of an angle expressed in radians.
<details><summary>Example</summary>

The following example calculates the sine of `PI` over three radians.

```sql
SELECT SIN(PI / 3) AS "sine"
```
Returns the following:

| `sine` |
| -- |
| `0.8660254037844386` |
</details>

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

## SQRT

Expand Down Expand Up @@ -1551,11 +1686,26 @@ Calculates the sum of a set of values.

## TAN

`TAN(expr)`
Calculates the trigonometric tangent of an angle expressed in radians.

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

Calculates the trigonometric tangent of an angle expressed in radians.
<details><summary>Example</summary>

The following example calculates the tangent of `PI` over three.

```sql
SELECT TAN(PI / 3) AS "tangent"
```
Returns the following:

| `tangent` |
| -- |
| `1.7320508075688767` |
</details>

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

## TDIGEST_GENERATE_SKETCH

Expand Down

0 comments on commit ca475a1

Please sign in to comment.