这是我的表的示例输出(time_entries)
user_name| entry_type | entry_datetime
User1 | Time In | 28-JUL-13 16:40:40
User1 | Time Out | 28-JUL-13 16:40:41
User2 | Time In | 28-JUL-13 16:41:13
User2 | Time Out | 28-JUL-13 16:41:15
User1 | Time In | 27-JUL-13 16:42:30
User1 | Time Out | 27-JUL-13 16:42:34
User2 | Time In | 27-JUL-13 16:43:32
User2 | Time Out | 27-JUL-13 16:43:35
现在我使用了这个查询
SELECT te.user_name, te.entry_name, MAX(te.entry_datetime) AS date
FROM time_entries AS te
GROUP BY te.entry_type, te.user_name
结果是这样的
user_name| entry_type | entry_datetime
User1 | Time In | 28-JUL-13 16:40:40
User1 | Time Out | 28-JUL-13 16:40:41
User2 | Time In | 28-JUL-13 16:41:13
User2 | Time Out | 28-JUL-13 16:41:15
问题:有没有办法在 1 行中合并具有相同名称的用户名?并有这样的输出。
user_name| Date | Timein | Timeout
User1 | 28-JUL-13 | 16:40:40 | 16:40:41
User2 | 28-JUL-13 | 16:41:13 | 16:41:15
我有点困惑如何去做。