Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
为什么对于每个 userId,以下子句不返回最后连接日期? 我在表中有 31 个不同的用户 ID,每个用户 ID 都有很多日期......
select userid, date from connections group by userid having date = max(date)
为什么要添加having限定符?如果您想要每个用户最后一次连接的最大日期,请尝试以下操作:
having
select userid, max(date) from connections group by userid;