我有下表:
+----+---------------------+-------------+-----------------+
| id | stat_time | reads | writes |
+----+---------------------+-------------+-----------------+
| 1 | 2013-07-18 20:00:00 | 42614543 | 1342129 |
| 2 | 2013-07-18 21:00:00 | 23085319 | 326139 |
| 3 | 2013-07-25 12:00:00 | 0 | 39639 |
| 4 | 2013-07-25 13:00:00 | 754166 | 39639 |
| 5 | 2013-07-25 14:00:00 | 693382 | 295323 |
| 6 | 2013-07-25 15:00:00 | 1334462 | 0 |
| 7 | 2013-07-25 16:00:00 | 10748367 | 261489 |
| 9 | 2013-07-25 17:00:00 | 4337294 | 0 |
| 10 | 2013-07-25 18:00:00 | 3002796 | 0 |
| 11 | 2013-07-25 20:00:00 | 3002832 | 0 |
| 12 | 2013-07-25 23:00:00 | 0 | 333468 |
| 13 | 2013-07-26 17:00:00 | 10009585 | 0 |
| 15 | 2013-07-26 18:00:00 | 6005752 | 0 |
| 17 | 2013-07-26 21:00:00 | 333663 | 0 |
+----+---------------------+-------------+-----------------+
我想做这样的事情:
SELECT stat_time, SUM(reads), SUM(writes) from this_table GROUP BY stat_time HAVING 'the same day'..
因此,输出三行的命令(一行用于 2013-07-18,第二行用于 2013-07-25,第三行用于 2013-07-26),并且在列中的每一行读取/写入中,总和为在这一天读/写。
谢谢你,大卫