?
Solved

SQL.  Format the dollar amount to include a comma.

Posted on 2007-03-23
4
Medium Priority
?
835 Views
Last Modified: 2012-05-05
SQL.  SQL 2000

How do I format a dollar amount to include the commas:

I have this statement:

Select   '$' + CONVERT(varchar(12), CAST(isnull(sum(totvalue),0) as numeric(10,2) ))  from vwtotvalue

Which returns $13892.32 , but I would also like it to have the commas:  $13,892.32
0
Comment
Question by:Epicmanagement
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 18781018
try
Select   '$' + CONVERT(varchar(12), convert(money,coalesce(sum(totvalue),0.00),0) )

 
0
 

Author Comment

by:Epicmanagement
ID: 18781034
NO.  That didn't return any commas.
0
 
LVL 50

Assisted Solution

by:Lowfatspread
Lowfatspread earned 747 total points
ID: 18781278
try
Select   '$' + CONVERT(varchar(12), convert(money,coalesce(sum(totvalue),0.00),1) )
0
 
LVL 19

Accepted Solution

by:
folderol earned 753 total points
ID: 18781370
Select   '$' + CONVERT(varchar(12), convert(money,coalesce(sum(totvalue),0.00)),1)

right parenthesis in wrong position.
no points to me please.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question