Search code examples
sqlitedecimal

SQLite is not displaying decimal values


I am using SQLite and have the following query:

select round((10/3), 5) as example

And it displays the following result:

example|
-------+
3.0    |

I've tried several approaches such as casting to float, rounding, and multiplying the field times 1.0; but nothing seems to work.

Does anyone know why this happens? And how to resolve it... Thank you in advance.


Solution

  • SQLite assumes an integer operation.

    You could try adding .0 to either 3.0 or 10.0:

    select round((10/3.0), 5) as example