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

# ATAN2

> Returns the angle of the point (x, y) measured from the positive x axis.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

Returns NULL when an argument is NULL.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
atan2(y, x)
```

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| y | TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE or DECIMAL(p, s) | Yes | The vertical coordinate. For DECIMAL(p, s), p is precision (total digits) and s is scale (digits after the decimal point). |
| x | TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE or DECIMAL(p, s) | Yes | The horizontal coordinate. For DECIMAL(p, s), p is precision (total digits) and s is scale (digits after the decimal point). |

## Returns

* Type: DOUBLE
* Possible values: An angle in radians from -pi through pi.
* NULL behavior: Returns NULL when an argument is NULL.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | No |

* Approximation bound: No fixed maximum error is guaranteed.

## Units

* Input unit: Coordinates in the same units
* Output unit: Radians
* Use degrees(result) to convert the result to degrees.

## Usage notes

* INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.
* Exact result: Floating-point computation can round the mathematical result.

## Examples

### Coordinates and NULL input

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT atan2(1, 1) AS "value", atan2(CAST(NULL AS DOUBLE), 1) AS null_value;
```

| value | null\_value |
| - | - |
| 0.7853981633974483 | NULL |

### Different quadrants

Results are in radians, rounded to six decimal places.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT round(atan2(CAST(1 AS DOUBLE), CAST(1 AS DOUBLE)), 6) AS first_quadrant, round(atan2(CAST(1 AS DOUBLE), CAST(-1 AS DOUBLE)), 6) AS second_quadrant;
```

| first\_quadrant | second\_quadrant |
| - | - |
| 0.785398 | 2.356194 |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.