Re: Averages
| From: | Diogo Zulli | Date: | Wed, 13 Dec 2000 16:46:55 +0000 |
| Subject: | Re: Averages | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30104@lists.php.net to get a copy of this message | ||
On [13 December 2000 11:33] (David Smith), wrote:
} I have a number field counting downloads and a date field. I would like to
} create a query showing most downloaded files using the average downloads a
} day via the date and count fields.
}
} Example.
}
} File 1 added 2000-12-11 15:27:22 total downloads = 98 average = 49/day
} File 2 added 2000-12-02 15:27:22 total downloads = 25 average = 2/day
} File 3 added 2000-12-13 15:27:22 total downloads = 158 average =
} 158/day
}
} Now I would like to use this info and create a query showing this info
} placing the most downloads a day on top. In this case:
}
} File 3, File 1, file 3.
}
} Any ideas to creating the statement?
}
} $query = "select * from warbirds_db WHERE FileCount Average of FileDate
} ORDER BY FileCount DESC LIMIT 0, 25";
I think you can get it by something like this:
SELECT *, FileCount / TO_DAYS((NOW() - added_date)) AS average
FROM warbirds_db
ORDER BY average DESC
- Diogo Zulli
----------------------[ www.sphynx.com.br ]---------------------------
"Why Live on The Edge When You Can BASE Jump Off It"