题解 | #统计作答次数#

统计作答次数

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

分析题目

题目条件:

三个概念,已完成,未完成,已做答的题目

初始提交版本:只利用了字段exam_id

select total_pv ,complete_pv,complete_exam_cnt
from (select count(exam_id) as total_pv from  exam_record) e1,
(select count(exam_id) as complete_pv from  exam_record  where submit_time is not null
or score is not null ) e2,
(select count(distinct exam_id) as complete_exam_cnt from  exam_record where submit_time is not null
or score is not null ) e3

改进:根据条件选取不同字段

1.利用count(null)=0 和if(条件,表达式1,表达式2)的知识点可以化子查询为更简洁的句子

count(distinct(if(submit_time is null,null,exam_id ))) as complete_exam_cnt from  exam_record
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-04 14:35
点赞 评论 收藏
分享
Southyeung:我说一下我的看法(有冒犯实属抱歉):(1)简历不太美观,给我一种看都不想看的感觉,感觉字体还是排版问题;(2)numpy就一个基础包,机器学习算法是什么鬼?我感觉你把svm那些写上去都要好一点。(2)课程不要写,没人看,换成获奖经历;(3)项目太少了,至少2-3个,是在不行把网上学习的也写上去。
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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