Cast integer to real

Posted by Dave Jarvis on Stack Overflow See other posts from Stack Overflow or by Dave Jarvis
Published on 2010-05-09T01:17:05Z Indexed on 2010/05/09 1:28 UTC
Read the original article Hit count: 322

Filed under:
|

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!

© Stack Overflow or respective owner

Related posts about mysql

Related posts about datatypes