题解 | #统计作答次数#

统计作答次数

https://www.nowcoder.com/practice/45a87639110841b6950ef6a12d20175f

# 有一个试卷作答记录表exam_record,请从中统计出总作答次数total_pv、
# 试卷已完成作答数complete_pv、已完成的试卷数complete_exam_cnt。

# 写法一:不用case when
# select count(id),count(score)
# ,(
#     select count(distinct exam_id)
#     from exam_record
# ) as complete_exam_cnt
# from exam_record

# 写法二:case when
select count(id)
,count(case when score is not null then 1 else null end )
,count(distinct CASE when score is not null then exam_id else null end)
from exam_record

全部评论

相关推荐

不愿透露姓名的神秘牛友
06-24 20:25
腾讯今年实习招了这么多人,后面秋招还会招人吗??想着秋招再战来着
牛客965593684号:腾讯好像2020年之后就是实习生招得多,应届生基本上不招,纯实习转正
点赞 评论 收藏
分享
晗江雪:其实我只是觉得你们导员说的很好笑
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务