Solved

Converting number to 2-digit in MS Query

Posted on 2011-09-25
5
265 Views
Last Modified: 2012-05-12

I am working on an MS Query and have the following code:

SELECT TempTable.Category, Sum(TempTable.`Dec 31, 09`), Sum(TempTable.`Dec 31, 10`), Sum(TempTable.`Jul 31, 11`)
FROM TempTable TempTable
WHERE (TempTable.Category<>'')
GROUP BY TempTable.Category

It produces what I expected and hoped for except for the extra long numbers.  Can someone tell me how to convert the number to 2 decimal places with commas as thousands separators?
0
Comment
Question by:BBlu
[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
  • 3
5 Comments
 
LVL 18

Accepted Solution

by:
Jerry Miller earned 125 total points
ID: 36596795
I would format the target cells with 2 decimals and use the ROUND function to make sure that your data is consistant.

ROUND(Sum(TempTable.`Dec 31, 10`),2)
0
 
LVL 13

Assisted Solution

by:lee555J5
lee555J5 earned 125 total points
ID: 36596876
If formatting the target cells is not an option in your project, try the Format command in your SQL statement. Look up the command in the help to see examples that may fit your need.

Lee
SELECT TempTable.Category, Format(Sum(TempTable.`Dec 31, 09`), "currency")
FROM TempTable TempTable
WHERE (TempTable.Category<>'')
GROUP BY TempTable.Category

Open in new window

0
 

Author Comment

by:BBlu
ID: 36597254
Thank you both, when I tried the Round() function, it seemed to work (code attached).  But when I try to do the currency version, which I need I guess if I want to include commas for thousands separators, I get an error.  Any idea why?

 MS Query-Format Error
0
 

Author Comment

by:BBlu
ID: 36597272
Never mind..it looks like II need to make 'currency' single quotes.. that worked.
0
 

Author Closing Comment

by:BBlu
ID: 36597306
Thank you both very much!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

728 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