排名

用户解题统计

过去一年提交了

勋章 ①金银铜:在竞赛中获得第一二三名;②好习惯:自然月10天提交;③里程碑:解决1/2/5/10/20/50/100/200题;④每周打卡挑战:完成每周5题,每年1月1日清零。

收藏

收藏日期 题目名称 解决状态
没有收藏的题目。

评论笔记

评论日期 题目名称 评论内容 站长评论
2025-05-14 分组与聚合函数(3)五花八门的项目,其实都有固定套路(1) 
好好的一个刷题网站,不能列举一些正常的例子吗?
如有冒犯请见谅。
1、趣味教学;
2、这是5年前我在某股份银行亲自做过的项目,不然不会有这么多灵感。

提交记录

提交日期 题目名称 提交代码
2025-05-23 CASE WHEN-老中青教师数量 
select
	case 
when year(enter_date) < 2000 then '资深教师'
when year(enter_date) >= 2010 then '青年教师'
	else '中年教师'
end as'teacher_type',
count(*) as 
		teacher_count
from
	teachers
group by 
	teacher_type
2025-05-23 CASE WHEN-男女学生的数量 
select
	case 
when gender = 'm' then '男'
when gender = 'f' then '女'
end as gender_text,
count(*) as student_count
from
	students
group by
	gender
2025-05-23 聚合函数-比较两位同学的数学成绩 
select
	student_id,max(score) as max_score,min(score) as min_score,avg(score) as avg_score
from
	scores
where
	(student_id = '460093' or student_id ='735011' ) and subject = '数学'
group by
student_id
2025-05-23 聚合函数-735011学生的语文成绩 
select
	max(score) as max_score,min(score) as min_score,avg(score) as avg_score
from
	students
inner join
	scores
on
	students.student_id = scores.student_id and students.student_id = '735011' and scores.subject = '语文'
2025-05-23 GROUP BY-年龄最大学生的出生日期 
select
	class_code,min(birth_date) as min_birth_date
from
	students
group by
	class_code
order by
	class_code
2025-05-23 GROUP BY-各科目最高分、最低分 
select
	subject,max(score) as max_score,min(score) as min_score
from
	scores
group by 
	subject
order by
	subject
2025-05-23 GROUP BY-各科目平均分 
select
	subject,avg(score) as average_score
from
	scores
where
	exam_date = '2024-06-30'
group by
	subject
order by
	subject
2025-05-23 GROUP BY-各班级人数 
select
	class_code,count(*) as student_count
from
	students
group by
	class_code
order by
	student_count desc
2025-05-22 条件过滤-没有职称的老教师 
select
	name,subject,class_code,enter_date
from 
	teachers
where
	year(enter_date) < 2010 and qualification is null
order by
	enter_date
2025-05-22 条件过滤-查找1994年至1997年毕业的女教师 
select
	name,subject,class_code,graduate_date
from
	teachers
where
	(year(graduate_date) between 1994 and 1997)
	and gender = 'f'
order by
	graduate_date
2025-05-22 条件过滤-符合条件的班主任 
select 
	name,subject,class_code,qualification
from
	teachers
where
	(fir_degr = '北京大学' or fir_degr = '清华大学')
and head_teacher is not null
order by
	name
2025-05-22 条件过滤-符合条件的班主任 
select 
	name,subject,class_code,qualification
from
	teachers
where
	fir_degr = '北京大学' or fir_degr = '清华大学'
order by
	name
2025-05-22 条件过滤-找出所有教授数学且具有高级职称的教师 
select
	name,subject,class_code,qualification
from
	teachers
where
	subject = '数学' and qualification = 'Senior'
order by 
	name
2025-05-22 条件过滤-查找2009年出生的女学生 
select
	students.student_id,students.name,students.birth_date
from
	students
where
	gender = 'f' and year(birth_date) = '2009'
order by
	birth_date
2025-05-22 条件过滤-查找2009年出生的女学生 
select
	students.student_id,students.name,students.birth_date
from
	students
where
	gender = 'm' and year(birth_date) = '2009'
order by
	birth_date
2025-05-22 数学成绩分段统计(1) 
select
	case 
when scores.score >= 0 andscores.score < 60 then '[0, 60)'
when scores.score >= 60 and scores.score < 90 then '[60, 90)'
when scores.score >= 90 and scores.score <110 then '[90, 110)'
when scores.score >= 110 and scores.score <=120 then '[110,120]'
end as 'score_range',
count(*) as num_students
from
	students
inner join
	scores
on
	students.student_id = scores.student_id
where
	scores.subject = '数学' and scores.exam_date = '2024-06-30'
group by
	score_range
2025-05-22 数学成绩分段统计(1) 
select
	case 
when scores.score >= 0 andscores.score < 60 then '[0, 60)'
when scores.score >= 60 and scores.score < 90 then '[60, 90)'
when scores.score >= 90 and scores.score <110 then '[90, 110)'
when scores.score >=110 and scores.score <=120 then '[1110,120]'
end as 'score_range',
count(*) as num_students
from
	students
inner join
	scores
on
	students.student_id = scores.student_id
where
	scores.subject = '数学' and scores.exam_date = '2024-06-30'
group by
	score_range
2025-05-22 S1年级物理成绩前10名(2) 
with ranked_scores as (
	select
		students.student_id,
		students.name,
		scores.score,
		rank() over (partition by students.grade_code order by scores.score desc) as ranking
	from
		students
	inner join
		scores
	on 
		students.student_id = scores.student_id
	where
		scores.subject = '物理' AND students.grade_code = 'S1'
)
select
	student_id,name,score,ranking
from
	ranked_scores
where
	ranking <10
2025-05-22 S1年级物理成绩前10名(1) 
with ranked_scores as(
	select 
		students.student_id,
		students.name,
		grade_code,
		physical_score.score,
		row_number()over(partition by grade_code order by score desc) as rnk
	from
		students
	inner join
		(select scores.student_id,scores.score from scores where subject = '物理') physical_score
	on 
		students.student_id = physical_score.student_id
)
select
	student_id,name,score,rnk
from
	ranked_scores
where
	grade_code = 'S1' and rnk <= 10
2025-05-21 S1年级物理成绩前10名(1) 
select 
	students.student_id,
students.name,
b.score,
	row_number()over(order by b.score desc) as rnk
from
	students
inner join
	(select scores.score,scores.student_id from scores where subject = '物理') b
on 
	students.student_id = b.student_id
where
	students.grade_code = 'S1'
order by
	rnk,student_id