Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- id user_id col1 col2 created_at
- 1 1 abc x 2019-01-04
- 2 2 def x 2019-02-01
- 3 3 ghi x 2019-03-05
- 4 2 jkl x 2019-07-07
- 5 2 mno x 2019-06-01
- 6 3 pqr x 2019-07-11
- select ud.*
- from (select ud.*,
- row_number() over (partition by user_id order by created_at desc) as seqnum
- from user_data ud
- ) ud
- where seqnum <= 10;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement