题解 | #分别满足两个活动的人#

分别满足两个活动的人

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

SELECT DISTINCT uid, 'activity1' AS sctivity
FROM exam_record
WHERE score >= 85 AND YEAR(submit_time)=2021
UNION
SELECT DISTINCT uid, 'activity2' AS sctivity
FROM (
    SELECT
        uid, start_time, submit_time, score, 
        TIMESTAMPDIFF(MINUTE,start_time,submit_time) AS spend_time,
        IF(TIMESTAMPDIFF(MINUTE,start_time,submit_time) < (duration/2),1,0) AS early_finish,
        difficulty
    FROM exam_record
    JOIN examination_info USING(exam_id)
) AS er_ei
WHERE difficulty='hard' AND score > 80 AND YEAR(submit_time)=2021
GROUP BY uid
HAVING SUM(early_finish) >= 1
ORDER BY uid;

全部评论

相关推荐

11-15 18:39
已编辑
西安交通大学 Java
全村最靓的仔仔:卧槽,佬啥bg呢,本也是西交么
点赞 评论 收藏
分享
11-02 09:49
已编辑
货拉拉_测试(实习员工)
热爱生活的仰泳鲈鱼求你们别卷了:没事楼主,有反转查看图片
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务