念_长征
念_长征
全部文章
分类
归档
标签
去牛客网
登录
/
注册
念_长征的博客
全部文章
(共166篇)
题解 | #满足条件的用户的试卷完成数和题目练习数#
# 查询高难度SQL试卷得分平均值大于80并且是7级的用户名id select er.uid from exam_record er join examination_info ei on er.exam_id=ei.exam_id join user_info ur on er.uid=ur.ui...
2023-12-28
0
178
题解 | #删除记录--timestampdiff()
delete from exam_record where timestampdiff(minute, start_time, submit_time)<5 and score<60;
2023-12-27
0
143
题解 | #每月及截止当月的答题情况#
/*关键点:窗口函数执行在select语句后面;select后面的窗口函数可以放在if()里面从而嵌一层判断(当然也可以靠子查询实现);sum()和max()作为窗口函数时,使用order by指定排序列,可实现起始-当前行的求和或取大(默认升序)*/ # 查询开始月份、uid、和新增用户判断列 s...
2023-12-27
0
195
题解 | #分别满足两个活动的人#--合并查询
# 查询2021年里,所有每次试卷得分都能到85分的人的id和活动号 # 使用if()函数是将指定值'activity1'与后面的别名区分,不然会运行报错 select uid, if(1=1, 'activity1', null) activity from exam_record er wh...
2023-12-26
0
191
题解 | 插入记录-先删除重复行再插入
delete from examination_info where exam_id=9003; insert into examination_info(exam_id, tag, difficulty, duration, release_time) values(9003, 'SQL', 'h...
2023-12-25
0
161
题解 | #第二快/慢用时之差大于试卷时长一半的试卷#
# 查询各试卷的答题记录的用时排序及此试卷的id select ei.exam_id, submit_time-start_time t_d, rank()over(partition by ei.exam_id order by submit_time-start_time desc) t_ran...
2023-12-25
0
151
题解 | #得分不小于平均分的最低分#
# 查询SQL试卷得分中不小于该类试卷平均得分的分数 select score from exam_record er inner join examination_info ei on er.exam_id=ei.exam_id where tag='SQL' and score >= (...
2023-12-24
0
156
题解 | #插入记录(二)#
insert into exam_record_before_2021(uid, exam_id, start_time, submit_time, score) select uid, exam_id, start_time, submit_time, score from exam_record...
2023-12-24
0
113
题解 | distinct关键字后面加两个字段,可以去重组合
# distinct关键字后面也可以加if()函数,再结合count()使用则可以实现指定条件下的计数操作 # 注意活跃天数是各个用户的不同上线日子总数之和 select date_format(start_time, '%Y%m') month, round(count(distinct uid,...
2023-12-24
0
526
题解 | 合并后排序,或使用子查询达成排序后合并的效果
# 先分别设计子查询来查询每个题目和每份试卷被作答的人数和次数并排序 # 然后查询已排序的结果并使用union合并结果 select * from ( select exam_id tid, count(distinct uid) uv, count(*) pv from exam_...
2023-12-23
0
179
首页
上一页
7
8
9
10
11
12
13
14
15
16
下一页
末页