All pastes #248733 Raw Edit

Unnamed

public text v1 · immutable
#248733 ·published 2006-11-14 23:08 UTC
rendered paste body
mysql>  SELECT CONCAT("Calculated difference between id ",t1.id," and id ",t2.id," is ",TIMESTAMPDIFF(SECOND,t1.time,t2.time)," seconds") AS difference FROM example AS t1, example AS t2 WHERE t1.id<t2.id GROUP BY t1.id;
+-------------------------------------------------------------+
| difference                                                  |
+-------------------------------------------------------------+
| Calculated difference between id 1 and id 3 is 1161 seconds |
| Calculated difference between id 3 and id 4 is 13 seconds   |
| Calculated difference between id 4 and id 5 is 11 seconds   |
+-------------------------------------------------------------+

mysql> SELECT * from example;
+----+---------------------+-------+
| id | time                | value |
+----+---------------------+-------+
| 1  | 2006-11-14 15:31:47 | 5     |
| 3  | 2006-11-14 15:51:08 | 9     |
| 4  | 2006-11-14 15:51:21 | 9     |
| 5  | 2006-11-14 15:51:32 | 9     |
+----+---------------------+-------+
4 rows in set (0.00 sec)