PostgreSQL DEGREES() Function
Summary: in this tutorial, you will learn how to use the PostgreSQL DEGREES()
function to convert radians to degrees.
Introduction to the PostgreSQL DEGREES() function
The DEGREES()
function converts radians to degrees. Here’s the syntax of the DEGREES()
function:
In this syntax, the radians_value
is a value in radians that you want to convert to degrees.
The DEGREES()
function returns the value of the radians_value
in degrees.
If the radians_value
is NULL
, the DEGREES()
function returns NULL
.
PostgreSQL DEGREES() function examples
Let’s take some examples of using the DEGREES()
function.
1) Basic DEGREES() function examples
The following example uses the DEGREES()
function to convert 1 radian to its equivalent degrees:
Output:
The following example uses the DEGREES()
function to convert the value of π (pi) radians to its equivalent in degrees:
Output:
Note that the PI()
function returns the value of π (pi) radians.
2) Using the DEGREES() function with table data
First, create a new table called angles
to store radian data:
Second, insert some rows into the angles
table:
Third, use the DEGREES()
function to convert radians to degrees:
Output:
Summary
- Use the PostgreSQL
DEGREES()
function to convert radians to degrees.