2行の違いが必要です
SELECT ( b.l2framessent - a.l2framessent ),
CONVERT((Min(a.datetime) DIV 500)*500, datetime)
+ INTERVAL 5 minute AS endOfInterval
FROM databasename.tablename a,
databasename.tablename b
WHERE a.ipaddress = 'moteid6'
AND b.ipaddress = 'moteid6'
AND a.datetime BETWEEN '2012-09-25 15:45:00' AND '2012-09-25 18:45:00'
GROUP BY a.datetime DIV 500;
両方の行は同じテーブル、データベース、同じ列からのものです
私は負の無関係な値を取得しています
正しい値を取得する方法
select datetime, l2framessent
from 6panview.Statistics3
where ipaddress = 'moteid6'
AND datetime BETWEEN '2012-09-25 15:45:00' AND '2012-09-25 18:50:00';
+---------------------+--------------+
| datetime | l2framessent |
+---------------------+--------------+
| 2012-09-25 17:45:56 | 25 |
| 2012-09-25 17:50:35 | 56 |
| 2012-09-25 17:55:15 | 87 |
| 2012-09-25 17:59:54 | 117 |
| 2012-09-25 18:04:33 | 148 |
| 2012-09-25 18:09:13 | 178 |
| 2012-09-25 18:13:52 | 208 |
| 2012-09-25 18:18:31 | 238 |
| 2012-09-25 18:23:10 | 269 |
| 2012-09-25 18:39:43 | 372 |
| 2012-09-25 18:44:23 | 402 |
| 2012-09-25 18:49:02 | 432 |
+---------------------+-----+