Hi all,
Essentially I was asked to look into a problem with a query at the office which
used AVG on a datetime column which produces incorrect results. (MySQL 4.1.10
on RHEL 3 update 4) As you can see below the stark difference between the
correct and incorrect results. Though, the incorrect
James Nobis [EMAIL PROTECTED] wrote on 04/12/2005
10:19:33 AM:
Hi all,
Essentially I was asked to look into a problem with a query at the
office which
used AVG on a datetime column which produces incorrect results. (MySQL
4.1.10
on RHEL 3 update 4) As you can see below the stark
Thanks for the detailed explanation which is what I assumed was
happening. Does
it make any sense though? Shouldn't we get some sort of warning for the
implicit cast? I could be wrong but I thought PostgreSQL, Oracle, and SQL
server handled avg(date/time values) correctly.
Quoting [EMAIL
I think that's because those databases render datetime values into their
seconds from epoch values (whichever epoch they use) when casting to a
numeric type (I know MS SQL does. I assume the others do, too.) It seems
that MySQL is the oddball on this issue.
Shawn Green
Database Administrator