Solved

SQL.  Format the dollar amount to include a comma.

Posted on 2007-03-23
4
813 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
  • 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 249 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 251 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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

932 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now