SQL Tutorial SQL Advanced SQL Database SQL References

Oracle ATAN2() Function



The Oracle (PL/SQL) ATAN2() function returns arc tangent of two numbers. The returned value will be in the range -𝜋 through 𝜋, depending on the signs of y and x, expressed in radians.

Syntax

ATAN2(y, x)

Parameters

y Required. Specify the first number used to calculate the arc tangent.
x Required. Specify the second number used to calculate the arc tangent.

Return Value

Returns the arc tangent of two numbers.

Example 1:

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

ATAN2(3, 5)
Result: .5404195002705841554435783646085999101395

ATAN2(2, 2)
Result: .7853981633974483096156608458198757210456

ATAN2(2, -2)
Result: 2.35619449019234492884698253745962716315

ATAN2(-2, 2)
Result: -.7853981633974483096156608458198757210456

ATAN2(-2, -2)
Result: -2.35619449019234492884698253745962716315

Example 2:

Consider a database table called Sample with the following records:

Datayx
Data 11010
Data 2-1010
Data 310-10
Data 4-10-10

To calculate the arc tangent of records of column y and column x, the following query can be used:

SELECT Sample.*, 
ATAN2(y, x) AS ATAN2_Value 
FROM Sample;

This will produce the result as shown below:

DatayxATAN2_Value
Data 11010.7853981633974483096156608458198757210456
Data 2-1010-.7853981633974483096156608458198757210456
Data 310-102.35619449019234492884698253745962716315
Data 4-10-10-2.35619449019234492884698253745962716315

❮ Oracle Functions