You can use the function FORMAT
as follows:
SELECT t.*,
CONCAT('de ', FORMAT(t.valor, 2, 'de_DE'), ' por ', FORMAT(t.desconto, 2, 'de_DE')) AS promocao
FROM (SELECT c.Valor as valor,
c.valor - c.valor * 20/100 AS desconto
FROM comissao c
ORDER BY c.valor DESC) t;
The result of the promotion column would be:
of 14,230,00 by 11,384,00
As to function:
FORMAT(X,D[,locale])
Formats the number X to a format like '#,###,##. #', rounded to D decimal Places, and Returns the result as a string. If D is 0, the result has no decimal point or fractional part.
The optional third Parameter Enables a locale to be specified to be used for the result number’s decimal point, thousands separator, and grouping between separators. ... . If no locale is specified, the default is 'en_US'.
Or in free translation:
Format a number X to a format '#,###,##. #' rounding to the decimal places D, and return the result as a string. If D is 0, the result has no decimal places.
The third (optional) parameter enables the locale specification used to determine the decimal separator, the thousands separator and the grouping between result separators. ... . If no location is specified, the default is 'en_US'.
I used the locality de_DE
because Germany uses the international standard that is the same that we use and the pt_BR
did not bring the separator of thousands.
Was the answer helpful? Don’t forget to mark to accept it. So you can use it if someone has a similar question!
– Sorack