题解 | #根据指定记录是否存在输出不同情况#

根据指定记录是否存在输出不同情况

https://www.nowcoder.com/practice/f72d3fc27dc14f3aae76ee9823ccca6b

SELECT ui.uid, 
SUM(IF(score IS NULL AND start_time IS NOT NULL,1,0)) incomplete_cnt, 
ROUND(AVG(IF(score IS NULL AND start_time IS NOT NULL,1,0)),3) incomplete_rate
from  user_info  ui
left join exam_record er using(uid)
where if((SELECT ui.uid FROM user_info as ui
    LEFT JOIN exam_record as er
    ON ui.uid = er.uid
    WHERE level = '0'
    GROUP BY ui.uid
    HAVING SUM(IF(score IS NULL AND start_time IS NOT NULL,1,0))>2) IS NOT NULL,
    level = '0', start_time IS NOT NULL)
group by ui.uid
order by incomplete_rate

全部评论

相关推荐

_hengheng:美赛啥时候有三等奖了,蓝桥杯优秀奖最好也别写,知道的面试官看了容易出事,能有菊厂实习也不算菜了
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务