题目链接:点击打开链接
题目大意:略。
解题思路:略。
AC 代码
WITH t AS(SELECT customer_id, product_id, COUNT(*) cnt FROM Orders GROUP BY customer_id, product_id), tt AS(SELECT customer_id, product_id, RANK() OVER(PARTITION BY customer_id ORDER BY cnt DESC) drk FROM t) SELECT customer_id, tt.product_id, product_name FROM tt JOIN Products USING(product_id) WHERE drk = 1