题目描述:
Write an SQL query to find the IDs of the users that requested a confirmation message twice within a 24-hour window. Two messages exactly 24 hours apart are considered to be within the window. The action does not affect the answer, only the request time.
Return the result table in any order.
The query result format is in the following example:
方法1:
主要思路:解题链接汇总
select distinct c1.user_id as user_id
from Confirmations as c1 join Confirmations as c2 on c1.user_id = c2.user_id
where c1.time_stamp<c2.time_stamp and TIMESTAMPDIFF(SECOND,c1.time_stamp,c2.time_stamp) <= 24*60*60
order by user_id