Wednesday, 18 May 2011

Beware the Integers of SQL

Most data miners improve by learning from their mistakes. Many software programs have their own little quirks and sometimes deliver answers that are not quite the answers to the question you thought you were asking...




select AVG(DaysInHospital) from DaysInHospital_Y2
-- 0

select AVG(DaysInHospital * 1.0) from DaysInHospital_Y2
-- 0.467101

select SUM(DaysInHospital) / COUNT(*) from DaysInHospital_Y2
-- 0

select SUM(DaysInHospital) * 1.0 / COUNT(*) from DaysInHospital_Y2
-- 0.467101542670

No comments:

Post a Comment