How to return "NaN" using SQRT
function in Oracle SQL? Here is my unsuccessful attempt:
SELECT SQRT(4) AS "SQRT of 4",
SQRT(0) AS "SQRT of 0",
SQRT(-1) AS "SQRT of -1"
FROM DUAL;
As I understand, a successful query might use the TO_BINARY_DOUBLE
function but additional approaches are welcome.
alexanderjsingletonalexanderjsingleton
asked Feb 19, 2016 at 18:47
1 Answer 1
Cast the number, as you said:
SELECT SQRT(4) AS "SQRT of 4",
SQRT(0) AS "SQRT of 0",
SQRT(TO_BINARY_DOUBLE(-1)) AS "SQRT of -1"
FROM DUAL;
alexanderjsingleton
2712 gold badges7 silver badges19 bronze badges
answered Feb 19, 2016 at 19:43
lang-sql