id user_id product_id
1 1 2
2 2 2
3 2 3
4 2 4
5 1 2
6 1 5
7 1 5
8 1 5
SELECT * FROM
(
select
ID
, LEAD(id) OVER (ORDER BY user_id) lead_id
from your_table
) tab
WHERE tab.id= tab.lead_id