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
Try this....
SELECT '$' + CONVERT(VARCHAR(100),CAST(3000000 AS MONEY),1)
RESULT: $3,000,000.00
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With