mysqlsql-servertype-conversionfloating-point-precision

MySQL Cast to Float or What Decimal value


I develop software for an insurance environment, so decimal values are very important. We are converting from MSSQL to MYSQL. The query my question relates to is:

SELECT CAST(
    CAST(
      (initialpremium - totalpremium) / 2 * 
      CAST(premiummultiplier AS INT) 
    AS FLOAT) 
FROM policy 
/* rest of the query... */

This code works in MSSQL but not in MYSQL. This is valid cast types for mysql.

The question that I have therefor is, is what is the correct decimal length for float. This link does not help. But describes converting from float to real in MSSQL and I have searched for float datasize mssql on the internet.


Solution

  • I found an answer. Instead of specifying decimal values in mysql you can just change the code to cast(value as DECIMAL)