G
Guest
I have been writing a simple query in Access 2003 to count records with a
calculated value greater than a threshhold. I entered a few different values
for the threshold into the query and tabulated the values. Getting bored with
this I decided to use a table with the different threshholds in it and
generate all the counts at once. I started to get different result counts
than the ones I had tabulated manually.
Here is a cut down version...
Table(Values), 1 record
[Prob] [Price]
0.39 5
Table(Threshhold), 1 record
[Exp]
0.95
All the fields are doubles
Query1:
SELECT Values.Prob, Values.Price, [Prob]*[Price]-1 AS ExpCalc
FROM [Values]
WHERE ((([Prob]*[Price]-1)>0.95));
When I run Query1 I get no results as expected since 0.39 * 5 - 1 = 0.95
Query2:
SELECT Values.Prob, Values.Price, [Prob]*[Price]-1 AS ExpCalc,
Threshhold.Above
FROM [Values], Threshhold
WHERE ((([Prob]*[Price]-1)>[Threshhold].[Above]) AND
((Threshhold.Above)=0.95));
When I run Query2 I get one result:
[Prob] [Price] [ExpCalc] [Above]
0.39 5 0.95 0.95
I can see that a rounding error could give me a result, but why does this
not apply to both queries? Is there something else I am missing here?
Ian.
calculated value greater than a threshhold. I entered a few different values
for the threshold into the query and tabulated the values. Getting bored with
this I decided to use a table with the different threshholds in it and
generate all the counts at once. I started to get different result counts
than the ones I had tabulated manually.
Here is a cut down version...
Table(Values), 1 record
[Prob] [Price]
0.39 5
Table(Threshhold), 1 record
[Exp]
0.95
All the fields are doubles
Query1:
SELECT Values.Prob, Values.Price, [Prob]*[Price]-1 AS ExpCalc
FROM [Values]
WHERE ((([Prob]*[Price]-1)>0.95));
When I run Query1 I get no results as expected since 0.39 * 5 - 1 = 0.95
Query2:
SELECT Values.Prob, Values.Price, [Prob]*[Price]-1 AS ExpCalc,
Threshhold.Above
FROM [Values], Threshhold
WHERE ((([Prob]*[Price]-1)>[Threshhold].[Above]) AND
((Threshhold.Above)=0.95));
When I run Query2 I get one result:
[Prob] [Price] [ExpCalc] [Above]
0.39 5 0.95 0.95
I can see that a rounding error could give me a result, but why does this
not apply to both queries? Is there something else I am missing here?
Ian.