// math reference

SQL ATAN function

Returns the arc tangent in radians for any real input: ATAN(0) is 0 and ATAN(1) is PI()/4.

Category
Math
Returns
float / double (radians)
In this category
36 of 82

Syntax

ATAN(number)

Engine support

EngineSupportNotes
SQL Server Yes Supported under this name.
PostgreSQL Yes Supported under this name.
MySQL Yes Supported under this name.
SQLite Yes Requires SQLite 3.35+ with the math functions built in
Oracle Yes Supported under this name.

Examples

Any engine

SELECT ATAN(0) AS zero, ATAN(1) AS quarter_pi;  -- 0, 0.7853...

PostgreSQL

SELECT DEGREES(ATAN(slope)) AS angle_deg
FROM ramps;

SQL Server

SELECT ATAN(1000000) AS near_right_angle;  -- 1.5707953267948966

Good to know

  • The result is between -PI()/2 and PI()/2. ATAN(1) and ATAN(-1) both point at 45-degree lines but cannot distinguish quadrants; use ATAN2 for that.
  • Unlike ASIN and ACOS there is no domain restriction: any real number, including huge ones, returns a valid angle.
  • ATAN(1) is PI()/4 only approximately; the last digits carry float error like every trig result.

Questions about ATAN

What is the difference between ATAN and ATAN2?

ATAN takes one number and returns an angle in (-PI/2, PI/2), losing quadrant information. ATAN2(y, x) takes both coordinates and returns the angle in the correct quadrant across the full circle.

Does ATAN have a domain error?

No. The tangent covers every real number, so ATAN accepts anything from minus to plus infinity without returning NULL or erroring.

Is the ATAN result in degrees?

No, radians. ATAN(1) is PI()/4, about 0.7854 radians, which is 45 degrees; wrap in DEGREES() for degrees.

Browse every function in the SQL function reference, or see what the SQLly desktop app does for your database.

Cheat sheets for the engines that have it: SQL Server, PostgreSQL, MySQL, SQLite, Oracle.

// fewer lookups

Functions your engine actually has

SQLly's completion lists the built-in functions of the engine you're connected to, whether that's SQL Server, PostgreSQL, MySQL, SQLite or Oracle. Hover a function for help, and signature hints show each argument as you type.