需求统计不同等级的会员增量数据,
结果集如下
使用的sql语句如下:
SELECT cu.level,COUNT(1) COUNT,DATE(cu.create_time) DATE,DAY(cu.create_time) DAY,WEEK(cu.create_time) WEEK,MONTH(cu.create_time) MONTH,YEAR(cu.create_time) YEAR
FROM zc_shop_card_user cu
WHERE cu.shop_id = '66901C618C04491D84B10300545954B2'
AND cu.create_time BETWEEN '2017-10-23' AND '2017-12-25'
GROUP BY DAY(cu.create_time),WEEK(cu.create_time),MONTH(cu.create_time),YEAR(cu.create_time),cu.level
现想得到以如下的样式的结果集:
date level1 level2 level3 level4
2017-12-01 143 11 7 0
2017-12-02 221 4 7 1
建议你在java里转换,不要把压力交给数据库.