PostgreSQL Tutorial PostgreSQL Advanced PostgreSQL Database Account Management PostgreSQL References
PostgreSQL Tutorial PostgreSQL Advanced PostgreSQL Database Account Management PostgreSQL References

PostgreSQL ATAN() Function



The PostgreSQL ATAN() function returns arc tangent of a value. The returned value will be in the range -𝜋/2 through 𝜋/2. The other variant of this function is ATAND() which returns the result in degrees.

Syntax

/* returns result in radians */
ATAN(x)

/* returns result in degrees */
ATAND(x)

Parameters

x Required. Specify the value.

Return Value

Returns the arc tangent of the value.

Example 1:

The example below shows the usage of ATAN() function.

SELECT ATAN(3);
Result: 1.2490457723982544

SELECT ATAN(0.5);
Result: 0.4636476090008061

SELECT ATAN(0);
Result: 0

SELECT ATAN(-3);
Result: -1.2490457723982544

SELECT ATAND(-3);
Result: -71.56505117707799

SELECT ATAND(0.5);
Result: 26.565051177077986

Example 2:

Consider a database table called Sample with the following records:

Datax
Data 1-1
Data 2-0.5
Data 30
Data 40.5
Data 51

The statement given below can be used to calculate the arc tangent of records of column x.

SELECT *, ATAN(x) AS ATAN_Value FROM Sample;

This will produce the result as shown below:

DataxATAN_Value
Data 1-1-0.7853981633974483
Data 2-0.5-0.4636476090008061
Data 300
Data 40.50.4636476090008061
Data 510.7853981633974483

❮ PostgreSQL Functions