题目链接:点击打开链接
题目大意:略。
解题思路:解决方案(1)代码通过,但是解决方案(2)为错误代码,但是没搞明白,为啥 AC 不了。
AC 代码
-- 解决方案(1) SELECT sell_date, COUNT(DISTINCT product) num_sold, GROUP_CONCAT(DISTINCT product ORDER BY product) products FROM Activities GROUP BY sell_date ORDER BY sell_date -- 解决方案(2) SELECT sell_date, COUNT(*) num_sold, GROUP_CONCAT(product) products FROM (SELECT * FROM Activities GROUP BY sell_date, product ORDER BY sell_date, product) t GROUP BY sell_date ORDER BY sell_date