Make a select statement output a number with commas
I am using SQL Server and am trying to figure out how to get a select statement to output a comma separated number. I can only find how to convert number to number with commas, which is not what I want. The following code is the code I am trying to get as a number with commas. Right now when you execute the statement it returns 750,000.00 and I want it to return 750,000.00.
code:
select max(c.salary) as MaxSalary
from #Career c inner join
#Member m
on c.Member_ID = m.Member_ID
where m.age < 35
+3
source to share
4 answers
You can use FORMAT()
for SQL Server 2012 forward
select FORMAT(750000.00, 'N', 'en-us') AS 'Numeric Format'
declare @table table(salary decimal(16,4))
insert into @table
values
(1234.00),
(64423.55)
select FORMAT(sum(salary), 'N', 'en-us') AS 'Numeric Format'
from @table
--or using your tables
select FORMAT(max(c.salary), 'N', 'en-us') AS 'Numeric Format'
from #Career c inner join
#Member m
on c.Member_ID = m.Member_ID
where m.age < 35
+2
source to share