John
John

Reputation: 952

Display sum with commas

I have a column called sum in my (mysql) database. This column has the type decimal(7,2). I am using the following statement to select the value from the database:

SELECT name, CONCAT('€ ', sum) as sum FROM payments

The sum is displayed like € 1000000.00.

Is it possible to display the data like € 1,000,000.00?

Does someone know how I can display the data like € 1,000,000.00?

Upvotes: 1

Views: 563

Answers (2)

Lululicious
Lululicious

Reputation: 31

you can use the format function:

   SELECT name, CONCAT('€ ', FORMAT(sum, 2)) as sum FROM payments; 

I also found a similar question: https://dba.stackexchange.com/questions/39419/mysql-format-numbers-with-comma

I hope this could be helpful. :D

Upvotes: 1

Gordon Linoff
Gordon Linoff

Reputation: 1269753

You want to use format():

SELECT name, CONCAT('€ ', FORMAT(sum, 2)) as sum
FROM payments

Upvotes: 5

Related Questions