疯狂叠if,参考了最热门解答大佬的分组方式 WITH niuuser_info AS (SELECT uid FROM user_info WHERE level=6 OR level=7) SELECT ni.uid,COUNT(DISTINCT DATE_FORMAT(active_record.time,'%Y%m')) AS act_month_total, COUNT(DISTINCT if(DATE_FORMAT(active_record.time,'%Y')=2021, DATE_FORMAT(active_record.time,'%Y%...