嗨我需要小查询这里是我的表
user table
userid username
user001 987
user002 123
user003 456
logintrack
usrid lastlogin
user001 7/22/2009
user001 7/23/2009
user002 7/24/2009
user001 7/25/2009
user003 7/26/2009
user002 7/25/2009
user001 7/26/2990
Expected Output
userid username lastlogin
user001 987 7/26/2009
user002 123 7/25/2009
user003 456 7/26/2009
此致 纳古
答案 0 :(得分:2)
不确定,但希望它有效,请尝试一下
SELECT u.userid, u.username, max(lt.lastlogin) FROM
user u, logintrack lt
WHERE u.userid = lt.userid
GROUP BY u.userid, u.username
答案 1 :(得分:2)
lastlogin不是该列的好名称,因为它是所有登录日期的列表,而不仅仅是最后一个。