Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL.  Format the dollar amount to include a comma.

Posted on 2007-03-23
4
Medium Priority
?
846 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
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.

636 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