Hi,
I've sometimes broused my way to an answer here, but this time I had to join and ask the question myself.
I'm using Access2010 on a Windows7 PC. The data is from an attached (via ODBC) SQL Server 2005 table,
named "Logbook", which contains some 1/4 million records.
I have a query which calculates a field for AverageWeight,
i.e. [TotalWeight]/[NumberItems] --> [AverageWeight]
It looks like this:
SELECT Weight, NumCount, [Weight]/[NumCount] AS WgtPer
FROM Logbook
WHERE ((Weight>0) AND (NumCount>0) AND (Area=15) AND (SubArea=3) AND (Code=1) AND (SubCode)=1) AND (Year=2012) AND (Counted=Yes))
ORDER BY [Weight]/[NumCount];
The query result produces 104 records, with WgtPer ranging from 1.000 to 3.441
Problem 1) When I ask it to Sort (Order By) on field [WgtPer], it doesn't do so correctly.
It appears to only sort on the Integer portion of the number, so the 1.xxx will appear first,
then the 2.xxx and finally the 3.xxx, but in all cases, the .xxx part is NOT sorted.
Is this normal expected behaviour ? If so, I don't understand why.
Also, if I take the above query and turn it into a MakeTable query, and create a little temp table,
then ask a new query to use that and Sort on WgtPer column, THEN it does it correctly.
Problem 2) If I use the (original) above query as the input to a new query, and ask for the Average value,
(ie select "Avg" in the Total option for field [WgtPer]), it gives the result 1.144 which is clearly Wrong. Why ?
If I again make the first query a MakeTable query and output the results to a Table,
and then base the second query on that table and ask for the "Avg", it returns the very reasonable
looking 1.734.
If Access is looking at the same 104 values in a Query as in a Table, WHY are the results different ?
My faith in Access has taken a beating today.
Thank You in advance to any Access gurus with answers.
I've sometimes broused my way to an answer here, but this time I had to join and ask the question myself.
I'm using Access2010 on a Windows7 PC. The data is from an attached (via ODBC) SQL Server 2005 table,
named "Logbook", which contains some 1/4 million records.
I have a query which calculates a field for AverageWeight,
i.e. [TotalWeight]/[NumberItems] --> [AverageWeight]
It looks like this:
SELECT Weight, NumCount, [Weight]/[NumCount] AS WgtPer
FROM Logbook
WHERE ((Weight>0) AND (NumCount>0) AND (Area=15) AND (SubArea=3) AND (Code=1) AND (SubCode)=1) AND (Year=2012) AND (Counted=Yes))
ORDER BY [Weight]/[NumCount];
The query result produces 104 records, with WgtPer ranging from 1.000 to 3.441
Problem 1) When I ask it to Sort (Order By) on field [WgtPer], it doesn't do so correctly.
It appears to only sort on the Integer portion of the number, so the 1.xxx will appear first,
then the 2.xxx and finally the 3.xxx, but in all cases, the .xxx part is NOT sorted.
Is this normal expected behaviour ? If so, I don't understand why.
Also, if I take the above query and turn it into a MakeTable query, and create a little temp table,
then ask a new query to use that and Sort on WgtPer column, THEN it does it correctly.
Problem 2) If I use the (original) above query as the input to a new query, and ask for the Average value,
(ie select "Avg" in the Total option for field [WgtPer]), it gives the result 1.144 which is clearly Wrong. Why ?
If I again make the first query a MakeTable query and output the results to a Table,
and then base the second query on that table and ask for the "Avg", it returns the very reasonable
looking 1.734.
If Access is looking at the same 104 values in a Query as in a Table, WHY are the results different ?
My faith in Access has taken a beating today.
Thank You in advance to any Access gurus with answers.