// math reference

SQL ASIN function

Returns the arc sine in radians: ASIN(1) is PI()/2 and ASIN(0.5) is about 0.5236 (30 degrees).

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

구문

ASIN(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 ASIN(1) AS half_pi;  -- 1.5707963...

PostgreSQL

SELECT DEGREES(ASIN(0.5)) AS thirty;  -- 30.000000000000004

MySQL

SELECT ASIN(1.2) AS out_of_domain;  -- NULL

알아 두면 좋은 정보

  • The domain is [-1, 1]. ASIN(2) returns NULL on MySQL and SQLite, raises 'input is out of range' on PostgreSQL, ORA-01428 on Oracle and an invalid floating point operation on SQL Server.
  • A computed ratio such as opposite / hypotenuse can come out at 1.0000000000000002 and then fails. Clamp it: ASIN(LEAST(1, GREATEST(-1, x))), or ASIN(MAX(-1, MIN(1, x))) on SQLite, which has no LEAST/GREATEST. SQL Server needs 2022+ for LEAST.
  • The result is radians; multiply by 180/PI() or wrap in DEGREES() for display.

Questions about ASIN

Why does ASIN return NULL for my value?

The input is outside [-1, 1], the only range where arc sine exists. MySQL and SQLite return NULL; PostgreSQL, Oracle and SQL Server raise an error instead. Clamp with LEAST/GREATEST (MAX/MIN on SQLite) when float noise may push values out.

Is the ASIN result in degrees?

No, radians on all engines. ASIN(0.5) is about 0.5236 radians, which is 30 degrees; wrap in DEGREES() to show it that way.

What is ASIN(1)?

PI()/2, about 1.5708 radians: the angle whose sine is 1 is a right angle.

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.