Dear Coders, I need a SELECT-command for the calculation of average data in a MySQL-database. I've got a MySQL database with normalized structure: timestamp (timestamp); sensor (int); value (dec) Name of the table: "dataset" "timestamp" is MySQL-timestamp, not UNIX-timestamp "value" and "sensor" can be NULL Unique Index is on fields: "timestamp" and "sensor" The data is 10-minute-average data from a weather station. Please have a look at the attached Excel-file! The first sheet "database-entries" contains dumped data from the SQL database. That's "real data", which you need to work with. Sometimes, a sensor has a failure - then its value is NULL. I've marked this with yellow color in the example. On the second sheet "average (30 minutes)" you can see the resulting table, I want to get. timestamp (timestamp); sensor (int); value (double); errors (int) "timestamp" is MySQL-timestamp "value" is the average data for the sensor "errors" is the count of NULL value in a sensor (see Excel-file) It should be possible to calculate various average data: - for 30 minutes - for 60 minutes - for 24 hours A small example for calculating 30-minute-average: 2008-05-05 07:00;0;32 2008-05-05 07:10;0;12 2008-05-05 07:20;0;15 2008-05-05 07:30;0;95 "2008-05-05 07:00" is NOT used for this calculation, since it's 10-minute-average data already! 07:00 contains the measurements from 06:51 to 07:00. result should be: 2008-05-05 07:30;0;40,66666667 (12 + 15 + 95) / 3 = 40,66666667 Please read the Excel-file correctly, please ask if you've got questions. Would be happy for a nice and easy solution with good support. Best regards, Lars-Daniel
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables):
a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment.
b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request.
3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).