mysql group by 之后要把名字放到一个字段里边

分组后的其他字段去重

count(DISTINCT(product)) num_sold,

分组后数据存放到一个字段 (带着排序,在保存到一个字段)

group_concat(distinct product order by product separator ‘,’)

select 
    sell_date,
    count(DISTINCT(product)) num_sold,
group_concat(distinct product order  by product  separator ',') 
products from  Activities group by sell_date order by sell_date

你可能感兴趣的:(mysql,数据库)