PostgreSQL CBRT() Function
The PostgreSQL CBRT() function returns the cube root of a given number.
Syntax
CBRT(number)
Parameters
number |
Required. Specify the number. |
Return Value
Returns the cube root of a given number.
Example 1:
The example below shows the usage of CBRT() function.
SELECT CBRT(2); Result: 1.2599210498948734 SELECT CBRT(3); Result: 1.4422495703074083 SELECT CBRT(10); Result: 2.1544346900318834 SELECT CBRT(50); Result: 3.6840314986403864 SELECT CBRT(100); Result: 4.641588833612778 SELECT CBRT(-64); Result: -4
Example 2:
Consider a database table called Sample with the following records:
Data | x |
---|---|
Data 1 | 0.5 |
Data 2 | 1 |
Data 3 | 5 |
Data 4 | 10 |
Data 5 | 50 |
The statement given below can be used to calculate the cube root of column x.
SELECT *, CBRT(x) AS CBRT_Value FROM Sample;
This will produce the result as shown below:
Data | x | CBRT_Value |
---|---|---|
Data 1 | 0.5 | 0.7937005259840998 |
Data 2 | 1 | 1 |
Data 3 | 5 | 1.7099759466766968 |
Data 4 | 10 | 2.1544346900318834 |
Data 5 | 50 | 3.6840314986403864 |
❮ PostgreSQL Functions