Advertisement
Guest User

Untitled

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