Question

In SQLite, you can use CAST([column] as text) to convert a result in a string, however, for double this will result in having 1 decimal. How can I control whether I want to display decimals or the number of decimals displayed.

Was it helpful?

Solution

Use the printf function:

> SELECT printf("%.3f", 1);
1.000
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top