如何计算彼此相距超过 20 分钟的事件组数?
考虑以下事件:
+---------------------+------------+
| S | D |
+---------------------+------------+
| 2024-07-21 07:01:48 | 2024-07-21 |
| 2024-07-21 07:01:49 | 2024-07-21 |
| 2024-07-21 07:02:03 | 2024-07-21 |
| 2024-07-21 07:09:50 | 2024-07-21 |
| 2024-07-21 07:10:18 | 2024-07-21 |
| 2024-07-21 07:10:40 | 2024-07-21 |
| 2024-07-21 12:12:01 | 2024-07-21 |
| 2024-07-21 12:12:18 | 2024-07-21 |
| 2024-07-21 12:12:28 | 2024-07-21 |
| 2024-07-21 12:12:57 | 2024-07-21 |
| 2024-07-21 12:13:21 | 2024-07-21 |
| 2024-07-21 12:19:59 | 2024-07-21 |
| 2024-07-21 12:20:28 | 2024-07-21 |
| 2024-07-21 12:20:42 | 2024-07-21 |
| 2024-07-21 17:03:37 | 2024-07-21 |
| 2024-07-21 17:04:17 | 2024-07-21 |
| 2024-07-21 17:04:28 | 2024-07-21 |
| 2024-07-21 17:04:40 | 2024-07-21 |
| 2024-07-21 19:41:51 | 2024-07-21 |
| 2024-07-21 19:42:30 | 2024-07-21 |
| 2024-07-21 19:42:32 | 2024-07-21 |
| 2024-07-21 19:55:22 | 2024-07-21 |
| 2024-07-21 19:55:31 | 2024-07-21 |
| 2024-07-21 19:55:59 | 2024-07-21 |
| 2024-07-21 19:56:07 | 2024-07-21 |
| 2024-07-21 20:04:12 | 2024-07-21 |
| 2024-07-21 20:04:48 | 2024-07-21 |
| 2024-07-21 20:05:01 | 2024-07-21 |
| 2024-07-21 20:05:19 | 2024-07-21 |
| 2024-07-22 07:07:56 | 2024-07-22 |
| 2024-07-22 07:07:57 | 2024-07-22 |
| 2024-07-22 07:08:23 | 2024-07-22 |
| 2024-07-22 07:08:40 | 2024-07-22 |
| 2024-07-22 07:08:51 | 2024-07-22 |
| 2024-07-22 07:16:09 | 2024-07-22 |
| 2024-07-22 07:16:44 | 2024-07-22 |
| 2024-07-22 07:17:06 | 2024-07-22 |
| 2024-07-22 07:17:07 | 2024-07-22 |
| 2024-07-22 12:15:24 | 2024-07-22 |
| 2024-07-22 12:15:34 | 2024-07-22 |
| 2024-07-22 12:15:53 | 2024-07-22 |
| 2024-07-22 12:16:05 | 2024-07-22 |
| 2024-07-22 12:25:11 | 2024-07-22 |
| 2024-07-22 12:26:00 | 2024-07-22 |
| 2024-07-22 12:26:14 | 2024-07-22 |
| 2024-07-22 15:08:46 | 2024-07-22 |
| 2024-07-22 15:08:55 | 2024-07-22 |
| 2024-07-22 15:09:23 | 2024-07-22 |
| 2024-07-22 15:09:49 | 2024-07-22 |
| 2024-07-22 15:10:33 | 2024-07-22 |
| 2024-07-22 15:11:06 | 2024-07-22 |
| 2024-07-22 15:18:54 | 2024-07-22 |
| 2024-07-22 15:19:34 | 2024-07-22 |
| 2024-07-22 15:19:57 | 2024-07-22 |
| 2024-07-22 19:13:16 | 2024-07-22 |
| 2024-07-22 19:29:23 | 2024-07-22 |
| 2024-07-22 19:29:24 | 2024-07-22 |
| 2024-07-22 19:30:03 | 2024-07-22 |
| 2024-07-22 19:30:56 | 2024-07-22 |
| 2024-07-22 19:41:08 | 2024-07-22 |
| 2024-07-22 19:42:06 | 2024-07-22 |
| 2024-07-22 19:42:07 | 2024-07-22 |
| 2024-07-22 19:42:29 | 2024-07-22 |
| 2024-07-22 19:42:34 | 2024-07-22 |
+---------------------+------------+
希望能够查询事件组彼此相隔超过 20 分钟的次数。
上述数据应产生以下结果:
+------------+-------+
| D | COUNT |
+------------+-------+
| 2024-07-22 | 4 |
| 2024-07-21 | 4 |
+------------+-------+
我开始对数据进行 dbfiddle,但不知道如何启动查询。