Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Query loses decimal places

Status
Not open for further replies.

MarcLodge

Programmer
Feb 26, 2002
1,886
GB
I have a spreadsheet with various worksheets in it. From these worksheets, I want to create another, based on the data in the previous worksheets. I've tried to do this using MS Query and SQL to grab the data and this works fine, except one of the columns I wish to display is a percentage valuation of two others. E.G
Total_Hours Hours_So_far %Complete
50 10 20

In order to do this I am dividing 10 by 50 and multiplying by 100. The answer I get back all the time is 0 and what I believe it is doing is dividing 10 by 50, getting 0.2 and losing the decimal place.

Both columns in the worksheets are formatted as numbers to two decimal places.

Does anyone have a clue on how to get round this?
 
Since you "do this using MS Query and SQL to grab the data" - could you share your query here?

By the way: "dividing 10 by 50 and multiplying by 100" - I would just divide 10 by 50 and format that column as Percentage


---- Andy

There is a great need for a sarcasm font.
 
Just remember (at least in MS-SQL). if you do an integer divide you get an integer. i.e, 10/3 = 3 but 10/3.0 = 3.3333.
 
There are times I use a query within a workbook and there are other times I'll only use a query to get a DISTINCT list of one or more values, but then use aggregation formulas to calculate my numeric values based on one or more criteria in a report row. My aggregation function of choice in most cases is the SUMPRODUCT() function. This would get you your average.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
AD1D550E-FCB5-4AB6-A3C8-1F86CACE2554_ne1bcz.jpg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top