SQL DEGREES function
Converts an angle from radians to degrees: DEGREES(PI()) is 180 and DEGREES(PI()/2) is 90.
- Category
- Math
- Returns
double; SQL Server returns the input's type- In this category
- 39 of 82
Syntax
DEGREES(angle_radians)
Engine support
| Engine | Support | Notes |
|---|---|---|
| SQL Server | Yes | Returns the input's type: DEGREES(1) is 57, DEGREES(1.0) is 57.295779513082322865 |
| PostgreSQL | Yes | degrees(double precision) only; numeric input is cast to double |
| MySQL | Yes | Built in |
| SQLite | Yes | Built in on 3.35+ |
| Oracle | Not built in | No DEGREES; use x * 180 / ACOS(-1) |
Examples
PostgreSQL
SELECT DEGREES(PI()) AS straight_angle; -- 180
PostgreSQL
SELECT DEGREES(ASIN(0.5)) AS thirty_degrees; -- 30.000000000000004
SQL Server
SELECT DEGREES(1) AS int_in, DEGREES(1.0) AS dec_in; -- 57, 57.295779513082322865
Oracle
SELECT 0.5236 * 180 / ACOS(-1) AS degrees FROM dual;
Good to know
- It is pure arithmetic: DEGREES(x) is x * 180 / PI(). On Oracle write x * 180 / ACOS(-1), since Oracle has neither DEGREES nor PI().
- Trig functions stay radian-only on every engine; DEGREES is for display and for converting results like ASIN(0.5) into 30.
- On SQL Server, DEGREES of an integer stays an integer and truncates: DEGREES(1) is 57, not 57.2958. Pass 1.0 or a float. Elsewhere small float noise appears instead: DEGREES(ASIN(0.5)) is 30.000000000000004.
Questions about DEGREES
What is the formula behind DEGREES?
x * 180 / PI(). On Oracle, which has neither function, write x * 180 / ACOS(-1).
Why does Oracle have no DEGREES?
It never shipped one, and it has no PI() either. Multiply manually: angle * 180 / ACOS(-1).
Does DEGREES make SIN accept degrees?
No. DEGREES converts radians to degrees, the opposite direction of what SIN needs. Convert degrees to radians with RADIANS() before calling trig functions.
Browse every function in the SQL function reference, or see what the SQLly desktop app does for your database.
Related on SQLly
Cheat sheets for the engines that have it: SQL Server, PostgreSQL, MySQL, SQLite.
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.