I have the following table:
+------------+-------+------------+-----------+
| date | time | custom_id | Number |
+------------+-------+------------+-----------+
| 01/17/2014 | 00:00 | ABC123 | 15 |
| 01/17/2014 | 00:00 | HEY567 | 25 |
| 01/17/2014 | 00:30 | ABC123 | 17 |
| 01/17/2014 | 00:30 | HEY567 | 28 |
| 01/17/2014 | 01:00 | ABC123 | 17 |
| 01/17/2014 | 01:00 | HEY567 | 28 |
| 01/17/2014 | 01:30 | ABC123 | 17 |
| 01/17/2014 | 01:30 | HEY567 | 28 |
+------------+-------+------------+-----------+
How can I sum 2 rows (Number) with the same CUSTOM_ID & DATE and when the given time is only :30 minutes of difference round it to :00 and delete the :30? It should look like this in the end:
+------------+-------+------------+-----------+
| date | time | custom_id | Number |
+------------+-------+------------+-----------+
| 01/17/2014 | 00:00 | ABC123 | 32 |
| 01/17/2014 | 00:00 | HEY567 | 53 |
| 01/17/2014 | 01:00 | ABC123 | 34 |
| 01/17/2014 | 01:00 | HEY567 | 56 |
+------------+-------+------------+-----------+
How can I accomplish this with PHP or possibly with a MySQL query?
SQLFiddle: http://sqlfiddle.com/#!2/cc529/1