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 | LoginTime
现在,我想使用表中的列来获取userid过去 7 天内未登录的那些。LoginTime
userid
LoginTime
任何帮助表示赞赏。谢谢。
如果每个用户只有一条记录
select UserID from table where LoginTime < dateadd(dd, -7, getdate())
如果您有一个用户的多条记录
select UserID from table group by UserID having max(LoginTime) < dateadd(dd, -7, getdate())