SELECT COUNT(*) 每天签到人数, DATE_FORMAT(creation_time,'%Y-%m-%d') 日期, SUM(amount) 每天送出HC FROM member_sign_record GROUP BY DATE_FORMAT(creation_time,'%Y-%m-%d')
SQL分组多列统计(GROUP BY后按条件分列统计)
SELECT DATE_FORMAT(create_time,'%Y-%m-%d') 日期,
SUM(CASE WHEN symbol ='HC' THEN amount END) 每天累计送出HC,
SUM(CASE WHEN symbol='CT' THEN amount END) 每天累计送出CT
FROM member_transaction WHERE type =6 and (symbol='CT' || symbol='HC') GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d')