MySQL from decimal(13.6) to currency

前端 未结 1 331
抹茶落季
抹茶落季 2021-01-28 15:28

I\'m trying to get from an decimal(13.6) value to currency in EURO\'s

I\'m getting this as result right now:

╔══════════════╦═════════╗
║   total      ║          


        
1条回答
  •  时光说笑
    2021-01-28 16:09

    This will give you a sum formatted in Euro:

    SELECT CONCAT('€', FORMAT(SUM(totalExcl), 2, 'de_DE')) AS total
    

    Will show: €8.890.905,86

    The other requested alternative:

    SELECT CONCAT('€M', FORMAT((SUM(totalExcl)/1000000), 1, 'de_DE')) AS total
    

    Will show: €M8,9

    Note that this example will show the sum according to standards (LOCALE de_DE), and not with the exact format you have requested, that have mixed dots "." and commas "," in a non standard way. This could easily be fixed with some string manipulation if you really must format the sum that way.

    0 讨论(0)
提交回复
热议问题