Search code examples
sqlsinglestore

MemSQL - How to cast integer/decimal values to Float in MemSQL?


I tried to convert integer/decimal values to Float but it returns a syntax error.I used the following sample query.

SELECT cast(order_quantity as float) t FROM demo limit 10   

It returned following error.

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'float) FROM demo limit 10' at line 1

So is there a way to cast to float in memsql?

Thank you in advance.


Solution

  • casts to float are not supported by MemSQL. The supported casts are listed here:

    CAST (input AS {BINARY | CHAR | DATE | DATETIME[(prec)] | DECIMAL[(prec [, scale])] | TIME[(prec)] | SIGNED [INTEGER] | UNSIGNED [INTEGER]})
    

    http://docs.memsql.com/v5.7/docs/convert

    Will a Decimal cast work?