select top 10 *
from James.activity_gc a
left join James.activity_gc as James.activity_gc1 b
on a.user_id = b.user_id
and a.time = b.time - interval '1' day
答案 0 :(得分:1)
问题标记为sql-server
,但Sql Server不使用Interval
关键字。相反,你这样做:
select top 10 *
from James.activity_gc a
left join James.activity_gc as James.activity_gc1 b
on a.user_id = b.user_id
and a.time = DATEADD(day, -1, b.time)
答案 1 :(得分:0)
对于MSSQL Server,您可以尝试
select top 10 *
from James.activity_gc a
left join James.activity_gc as James.activity_gc1 b
on a.user_id = b.user_id
and DATEDIFF(day, a.time, b.time) = 1