+----------+--------------+-------------------------+
| ticketid | ticketpostid | date |
+----------+--------------+-------------------------+
| 1387935 | 3147808 | 2012-09-17 13:33:01 |
| 1387935 | 3147812 | 2012-09-17 13:33:41 |
| 1387938 | 3147818 | 2012-09-17 13:35:01 |
| 1387938 | 3148068 | 2012-09-17 13:37:01 |
| 1387938 | 3148323 | 2012-09-17 14:47:01 |
| 1387939 | 3147820 | 2012-09-17 13:36:01 |
| 1387939 | 3147834 | 2012-09-17 13:36:25 |
| 1387939 | 3147851 | 2012-09-17 13:41:01 |
| 1387939 | 3147968 | 2012-09-17 13:59:06 |
| 1387939 | 3147996 | 2012-09-17 14:03:01 |
这是我写的查询的结果。有两行和两行以上具有相同的ticketid。我需要在每个ticketid中找到前两个日期之间的时差
前任。
+----------+--------------+-------------------------+
| ticketid | ticketpostid | date |
+----------+--------------+-------------------------+
| 1387935 | 3147808 | 2012-09-17 13:33:01 |
| 1387935 | 3147812 | 2012-09-17 13:33:41 |
| 1387938 | 3147818 | 2012-09-17 13:35:01 |
| 1387938 | 3148068 | 2012-09-17 13:37:01 |
| 1387939 | 3147820 | 2012-09-17 13:36:01 |
| 1387939 | 3147834 | 2012-09-17 13:36:25 |
因此;
+----------+--------------+
| ticketid |time diff(sec)|
+----------+--------------+
| 1387935 | 40 |
| 1387938 | 120 |
| 1387939 | 24 |
你能告诉我我该怎么做吗?
谢谢。