Can anyone help me format my dollars data into millions of dollars for SQL Server?
3,000,000
--> $3M
I have this but it's not working
SELECT '$' + SUM(Sales_Information.Sales_in_Dollars / 1000000)
AS [Sales in Millions]
Doing this gives me #Error
format(SUM(Sales_Information.Sales_in_Dollars / 1000000)
The FORMAT
function has a way of trimming the thousands
each comma reduces the displayed value by 1000
e.g.
select format(3000000,'$0,,,.000B')
select format(3000000,'$0,,M')
select format(3000000,'$0,K')
(note that I had to use decimals to show 3 million in Billions)
Output:
$0.003B
$3M
$3000K
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments