how to use order by with collect_set() operation in hive

后端 未结 2 2051
滥情空心
滥情空心 2021-02-04 21:21

In Table 1, I have customer_id, item_id and item_rank (rank of item according to some sales). I want to collect a list of items for each customer_id and arrange them according

2条回答
  •  广开言路
    2021-02-04 21:35

    SELECT customer_id, collect_set(item_id) AS item_list FROM table1 GROUP BY customer_id ORDER BY item_rank

    NOTE : Using collect_list() gives you duplicates and collect_set() gives you unique values.

提交回复
热议问题