Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. cookie page_num,
  2. 1234 1
  3. 1234 2
  4. 1234 3
  5. 1234 4
  6. 4444 1
  7. 4444 2
  8.  
  9. select cookie, collect_set(page_num) as page_set
  10. from mytable
  11. group by cookie
  12.  
  13. 1234 [1,2,3,4]
  14. 4444 [1,2]
  15.  
  16. 1234 [2,4,1,3]
  17. 4444 [2,1]
  18.  
  19. SELECT cookie, map_keys(
  20. collect_max( page_num, row_order, MAX_NUM_PAGES ) )
  21. FROM (
  22. SELECT cookie, page_num, group_count( cookie ) as row_order
  23. FROM mutable
  24. DISTRIBUTE BY cookie
  25. SORT BY cookie, my_sort_column
  26. ) sc
  27. GROUP BY cookie;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement