I am trying to find a way to format any large number 1000 or more with commas in SQlite. So, 1000 would be 1,000. 1000000 would be 1,000,000, and so on.
I can easily handle individual cases by changing the numbers to text and then using SUBSTR, but I need a catch all solution that can be done in SQLite.
Any help is appreciated.
You can do it with the function printf()
:
SELECT printf("%,d", col)
FROM tablename
Replace tablename
and col
with your table's and the column's name.
See the demo.