假设我有一张Connections
表格[logID, user, time]
一个示例集是:
| logID | user | time
|-----------------------
| 91 | terry | 12:55:00 <--- Last by user
| 90 | terry | 12:54:26
| 89 | nami | 12:52:12 <--- Last by user
| 88 | terry | 12:50:50 <--- Last by user
| 87 | terry | 12:49:21
| 86 | terry | 12:48:16
| 85 | terry | 12:46:07
| 84 | nami | 12:31:22 <--- Last by user
| 83 | nami | 12:30:30
| 82 | nami | 12:29:26
| 81 | terry | 12:27:12 <--- Last by user
所需的查询应在用户列更改时对它进行 GROUP,并选择该用户的最后一个时间戳:
| logID | user | time
|-----------------------
| 91 | terry | 12:55:00 <--- Last by user
| 89 | nami | 12:52:12 <--- Last by user
| 88 | terry | 12:50:50 <--- Last by user
| 84 | nami | 12:31:22 <--- Last by user
| 81 | terry | 12:27:12 <--- Last by user
我一直在玩 GROUP BY,但没有得到任何地方......