How to format the numbers directly through SQL

1

Gentlemen, my numbers are coming out unformatted when I make the select directly in the bank, they are coming out as follows:

REALIZADO             META
61274436,2090003    80000000,00

How can I make them readable for anyone to interpret?

    
asked by anonymous 30.07.2018 / 20:50

1 answer

2

Using SQL SERVER 2012 , you can use the FORMAT :

SELECT FORMAT(A.REALIZADO,'#,0.0000', 'pt-BR') ...

Using only the '# 0.0000' pattern will format the display using punctuation, but will appear according to the SQL Server setting, which if set to English for example will display "61,274,436,2090" . To display in the correct format, use the last parameter, which is the "culture", in the example, I used "pt-BR" to display periods in the thousands and commas in the decimals.

Can be used with both numeric and date types, check the table in the link above with the documentation.

    
30.07.2018 / 21:22