Cast integer to real
- by Dave Jarvis
Question
How do you cast an INTEGER value as a REAL value?
Attempts
CAST( Y.YEAR AS REAL), but that failed (the documentation indicates you cannot CAST or CONVERT values to REALs.
Y.YEAR + 0.0, but that failed, too.
Error Message
Using udf_slope fails due to:
Can't initialize function 'slope'; slope() requires a real as parameter 2
Code
SELECT
D.AMOUNT,
Y.YEAR,
slope(D.AMOUNT, Y.YEAR + 0.0) as SLOPE,
intercept(D.AMOUNT, Y.YEAR + 0.0) as INTERCEPT
FROM
YEAR_REF Y,
DAILY D
Here, D.AMOUNT is a FLOAT and Y.YEAR is an INTEGER.
Thank you!