// 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.

카테고리
Math
Returns
float / double (radians)
In this category
36 of 82

구문

ATAN(number)

엔진 지원

엔진Support메모
SQL Server 예 Supported under this name.
PostgreSQL 예 Supported under this name.
MySQL 예 Supported under this name.
SQLite 예 Requires SQLite 3.35+ with the math functions built in
Oracle 예 Supported under this name.

예시

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

알아 두면 좋은 정보

  • 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.