提供Mysql下一种相当粗暴的解法……看了一下好像还没有人发过 select user_info.uid, ifnull(count(distinct month),0) a1, ifnull(count(distinct day),0) a2, ifnull(count(distinct examday),0), ifnull(count(distinct questionday),0) from ( select uid, date_format(a.start_time,'%Y%m') month, if(year(...