2017-06-22 103 views

回答

0

這個答案似乎像什麼你問:

SQL most recent using row_number() over partition

換句話說:

SELECT user_id, page_name, recent_click 
FROM (
    SELECT user_id, 
     page_name, 
     row_number() over (partition by session_id order by ts desc) as recent_click 
    from clicks_data 
) T 
WHERE recent_click between 2 and 5