题解 | #未完成试卷数大于1的有效用户#
未完成试卷数大于1的有效用户
http://www.nowcoder.com/practice/46cb7a33f7204f3ba7f6536d2fc04286
请问为什么这样得到的detail拼接出来的顺序不一样?
SELECT
uid,
COUNT(IF(submit_time is NULL, 1, NULL)) incomplete_cnt,
COUNT(IF(submit_time, 1, NULL)) complete_cnt,
group_concat(concat_ws(':', date(start_time), tag) SEPARATOR ';') detail
FROM exam_record er JOIN examination_info ei USING(exam_id)
WHERE year(start_time) = 2021
GROUP BY uid
HAVING incomplete_cnt > 1 AND incomplete_cnt < 5 AND complete_cnt >= 1
ORDER BY incomplete_cnt desc;