Solved

Divide in Access Query Won't display results less than 1

Posted on 2004-08-16
7
1,155 Views
Last Modified: 2008-01-09
Hi all,
I have been trying to get an expression to work in an Access query. I thought i was writing my code wrongly until i decided to try a simple sum instead...  

SELECT     2 / 10 AS [Sum]

This equals 0 according to access. If I change it to :

SELECT     2 * 10 AS [Sum]

This equals 20, as you would expect.

Why won't access divide numbers where the total is less than zero??

0
Comment
Question by:crich
7 Comments
 
LVL 15

Expert Comment

by:will_scarlet7
ID: 11808534
I think it might just be a problem access rounding your sum as 2 devided by 10  will equal .2 which comes to 0 when rounded off.
0
 
LVL 2

Accepted Solution

by:
namliam_eht earned 50 total points
ID: 11808796
Default for an expresion field is an integer, you need to change it ... to a double?! or single... format


Greetz
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 11808953
what version of Access are you using, as I just entered

SELECT     2 / 10 AS [Sum]


in Access 97 and 2002, and got 0.2 as the result, so there must be something else that you are doing, but not telling us in your question.  EXACTLY what are you trying, and what does the complete SQL look like?

AW
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 49

Expert Comment

by:Gustav Brock
ID: 11810096
Either you have written:

  SELECT 2 \ 10 AS [Sum]

or you have set the Format property of that field to something with zero decimals. That (Format) will, however, only affect the way the number is displayed, not the actual value, 0.2.

/gustav

0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 11812331
2 \ 10 does, in Access, what is called INTEGER division, which returns the INTEGER value of the division, not the 'real' result


2\ 10 ==> 0

2/ 10 ==> 0.2

AW
0
 

Author Comment

by:crich
ID: 11911574
I think the problem is because i was using views in views on sql server and maybe views forget datatypes?? I had to use CONVERT(decimal, table.field) to get the right calculations.
0
 

Author Comment

by:crich
ID: 11911576
Am accepting this as i think it was the closest as it related to datatypes.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Single Step Macro 4 41
SQL Select in Access 2003 3 23
Signature required on a report 5 30
Number of records returned on a form 5 22
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

808 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