题解 | #统计作答次数#

统计作答次数

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

select count(start_time) as total_pv,
count(submit_time) as complete_pv,
count(distinct if(submit_time is not null,exam_id,null)) as complete_exam_cnt
from exam_record;

三个知识点:

  • count(*)和count(字段)的区别,count(*)包含所有的字段,包括null和空,而count(字段)不包括null但是包括空.
  • count中可以加条件
  • if (exp1,exp2,exp3) 如果exp1成立,那么结果为exp2,否则结果为exp3.
全部评论

相关推荐

06-13 15:45
辽宁大学 golang
咱就是说 你不主动 我也不会主动下一步hhh,急死了
恶龙战士:不建议把这种帖子发到牛客上,建议去小红书发
点赞 评论 收藏
分享
每晚夜里独自颤抖:这个在牛客不是老熟人了吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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