Avg() not including 0's



Hi,

I have a sql query like this

select avg([mycolumn]) from data where date > '1/5/08' and date <
'1/10/08'
group by [mycolumn]
order by [mycolumn] desc

If all values within that average are numbers, I'm fine. If it's a 0
(not a null, a 0) it doesn't get averaged in. For instance, values
0,1,2 should produce an average of 1.

(0+1+2)/3 = 1.

But sql is returning a value as if my 0's were nulls and not factored
in:

(1+2)/2 = 1.5

Does anyone know why this is happening and how to fix it?
.



Relevant Pages

  • PAFileDB SQL Injection Vulnerability & Ratings Cheat Fix
    ... I recently found out that someone I knew was running this vuln ... After informing them it was vuln they were dissapointed at ... here is a quick fix i threw together to take care ... I also closed off the variable in the SQL query that was allowing the SQL ...
    (Bugtraq)
  • Re: NULL comparison failure in sql query
    ... the 'right' way to do this is to properly handle NULLs in your ... SQL Server MVP ... > I want to compare 2 fields in a table considering the equality of the ... > in the sql query)? ...
    (microsoft.public.sqlserver.programming)
  • Re: SQL Query Building Problem??
    ... Could Anybody please give me prompt reply?? ... I really need to fix that ... TIA ... > I have problem while making a SQL Query. ...
    (microsoft.public.sqlserver.programming)
  • Set column to null
    ... but it fails. ... myColumn is a Long type. ... i know it can accept nulls because i get some nulls from the database. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Set column to null
    ... You have to use the DbNull value instead of null ... myColumn is a Long type. ... i get some nulls from the database. ...
    (microsoft.public.dotnet.framework.adonet)