user_id | views
1 | 20
2 | 5
3 | 10
1 | 30
user_id | views
1 | 30
3 | 10
2 | 5
1 | 20
select *
from tbl
order by row_number() over(partition by user_id order by views desc), views desc;