Order of Precedent in SQL



Hi guys
Hope someone can help.

I have a field in a table that has '0' as a default value that
indicates that no result has been temporarily stored.
When updated many of these values will change to the range of 95.00 to
103.00. Others will stay at '0'.

I am attempting to create a Sql statement that will return the average
of the non zero values.

In the QBE grid I can see all these values. When I add the criteria
'>0', I see only the non zero values.
However, when I select the aggregate function and choose Avg, it
returns a value of 84 instead of something between 95.00 and 103.00.
It seems to me that this might indicate that the SQL is averaging all
values and ignoring the criteria field. Not what I am after.

Pseudo code is similar to this:
SELECT Avg(tblTable1.field1)
FROM
WHERE this AND that AND ((Avg(tblTable1.field1)>0)

Can anyone point me to an example code that would allow me to first
select the non zero values and then average only those values?
Cheers

Remove undies to reply
.



Relevant Pages

  • Re: Order of Precedent in SQL
    ... I see only the non zero values. ... >values and ignoring the criteria field. ... >Pseudo code is similar to this: ... >Remove undies to reply ...
    (microsoft.public.access.queries)
  • Re: Order of Precedent in SQL
    ... Your filter is not to omit those whose average is not> 0, ... > I am attempting to create a Sql statement that will return the average ... I see only the non zero values. ... > values and ignoring the criteria field. ...
    (microsoft.public.access.queries)
  • Re: Use of Nz functions
    ... Can you post the SQL statement that is not working. ... This will replace all null values with Zero. ... you don't need to use NZ since Sum ignores nulls. ... you coud use the Val function. ...
    (microsoft.public.access.queries)
  • SQL Help???
    ... i am trying to run a simple SQL statement from my C# app to return a number ... of records, however when i do my record count is always zero, but i know ... the code executes fine... ...
    (microsoft.public.dotnet.languages.csharp)
  • SQL Help???
    ... i am trying to run a simple SQL statement from my C# app to return a number ... of records, however when i do my record count is always zero, but i know ... the code executes fine... ...
    (microsoft.public.data.oledb)