34,571
社区成员
发帖
与我相关
我的任务
分享
select b.书籍,t2.书籍 as 之后书籍
from #book b
join #tb t on t.书籍 = b.书籍
join #tb t2
on t2.用户 = t.用户 and t2.id > t.id
and not exists(
select 1 from #tb where 用户 = t2.用户 and id > t.id and id < t2.id
)
where datediff(hour,t.时间,t2.时间) < 24
group by b.书籍,t2.书籍
order by b.书籍,count(*)