排名

用户解题统计

过去一年提交了

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

收藏

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

评论笔记

评论日期 题目名称 评论内容 站长评论
没有评论过的题目。

提交记录

提交日期 题目名称 提交代码
2026-03-05 HAVING-语数英优异的学生 
select
	student_id,
sum(score) as total_score
from scores
where subject in ('语文','数学','英语')
	and exam_date = '2024-06-30'
group by student_id
having sum(score) > 330
order by total_score desc;
2026-03-05 HAVING-语数英优异的学生 
select
	student_id,
sum(score) as total_score
from scores
where subject in ('语文','数学','英语')
	and exam_date = '2024-06-30'
group by student_id
having sum(score) > 330
order by total_score;
2026-03-05 HAVING-执教教师超过3人的科目 
select subject
from teachers
group by subject
having count(distinct teacher_id) >= 3
2026-03-05 HAVING-每次成绩都不低于80分的学生 
select student_id,max(score) max_score, min(score) min_score, avg(score) avg_score
from scores
group by student_id
having min(score)>=80
order by student_id
2026-03-05 CASE WHEN-老中青教师数量 
select
	case
	when year(enter_date) >= 2010 then '青年教师'
when year(enter_date) <= 2000 then '资深教师'
else '中年教师'
end as teacher_type,
count(distinct teacher_id) as teacher_count
from teachers
group by teacher_type
2026-03-05 CASE WHEN-男女学生的数量 
select
	case 
	when gender = 'm' then '男'
when gender = 'f' then '女'
end as gender_text,
count(distinct student_id) as student_count
from students
group by gender_text
2026-03-05 聚合函数-比较两位同学的数学成绩 
select
	student_id,
max(score) as max_score,
min(score) as min_score,
avg(score) as avg_score
from scores a
where a.student_id in ('460093','735011')
	and a.subject = '数学'
group by student_id
2026-03-05 聚合函数-735011学生的语文成绩 
SELECT
MAX(score) AS max_score,
MIN(score) AS min_score,
AVG(score) AS avg_score
FROM scores
WHERE student_id = '735011' 
AND subject = '语文';
2026-03-05 条件过滤-没有职称的老教师 
select 
	name,
subject,
class_code,
enter_date
from teachers 
where year(enter_date) < 2010
	and qualification is null
order by enter_date asc;
2026-03-05 条件过滤-查找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;
2026-03-05 条件过滤-符合条件的班主任 
select 
	name,
subject,
class_code,
qualification
from teachers 
where fir_degr in ('北京大学','清华大学')
	and head_teacher is not null
order by name;
2026-03-05 条件过滤-符合条件的班主任 
select 
	name,
subject,
class_code,
qualification
from teachers 
where fir_degr in ('北京大学','清华大学')
order by name;
2026-03-05 条件过滤-找出所有教授数学且具有高级职称的教师 
select 
	name,
subject,
class_code,
qualification
from teachers
	where subject = '数学'
and qualification = 'Senior'
order by name asc;
2026-03-02 平均分最高的班级 
WITH student_total_scores AS (
    SELECT 
        s.class_code, 
        s.student_id, 
        SUM(sc.score) AS total_score
    FROM 
        students s
    JOIN 
        scores sc ON s.student_id = sc.student_id
    WHERE 
        sc.exam_date = '2024-06-30'
    GROUP BY 
        s.class_code, s.student_id
),
class_averages AS (
    SELECT 
        sts.class_code, 
        COUNT(DISTINCT sts.student_id) AS num_students, 
        SUM(sts.total_score) AS class_total_score
    FROM 
        student_total_scores sts
    GROUP BY 
        sts.class_code
)
SELECT 
    ca.class_code, 
    ca.num_students, 
    ROUND(ca.class_total_score / ca.num_students, 2) AS avg_score, 
    t.name AS head_teacher_name
FROM 
    class_averages ca
JOIN 
    teachers t ON t.class_code LIKE CONCAT('%', ca.class_code, '%')
WHERE 
    t.head_teacher = ca.class_code
ORDER BY 
    avg_score DESC
2026-03-02 化学老师的教学成果 
WITH total_students AS (
    SELECT 
        t.name AS teacher_name, 
        COUNT(DISTINCT s.student_id) AS total_students
    FROM 
        teachers t
    JOIN 
        students s ON t.class_code LIKE CONCAT('%', s.class_code, '%')
    WHERE 
        t.subject = '化学'
    GROUP BY 
        t.name
),
failed_students AS (
    SELECT 
        t.name AS teacher_name, 
        COUNT(DISTINCT s.student_id) AS failed_students
    FROM 
        teachers t
    JOIN 
        students s ON t.class_code LIKE CONCAT('%', s.class_code, '%')
    JOIN 
        scores sc ON s.student_id = sc.student_id
    WHERE 
        t.subject = '化学'
        AND sc.subject = '化学'
        AND sc.score < 60
    GROUP BY 
        t.name
)
SELECT 
    ts.teacher_name, 
    ts.total_students, 
    fs.failed_students, 
    ROUND((fs.failed_students / ts.total_students) * 100, 2) AS failure_rate
FROM 
    total_students ts
JOIN 
    failed_students fs ON ts.teacher_name = fs.teacher_name
ORDER BY 
    failure_rate DESC;
2026-03-02 优异物理成绩的分布 
select
	a.class_code,
count(distinct a.student_id) as num_students_90_plus,
round(avg(b.score),2) as avg_score_90_plus,
c.name as physics_teacher
from students a
join scores b on a.student_id = b.student_id
join teachers c on c.class_code likeCONCAT('%', a.class_code, '%')
where b.exam_date = '2024-06-30'
		and b.subject = '物理'
and b.score >= 90
and c.subject = '物理'
group by a.class_code,c.name
order by avg_score_90_plus desc;
2026-03-02 条件过滤-查找2009年出生的女学生 
select 
	student_id,
name,
birth_date
from students a
where a.gender = 'f' and year(a.birth_date) = '2009'
order by birth_date asc
2026-03-02 条件过滤-查找2009年出生的女学生 
select 
	student_id,
name,
birth_date
from students a
where a.gender = 'm' and year(a.birth_date) = '2009'
order by birth_date asc
2026-03-01 优异物理成绩的分布 
select
	a.class_code,
count(1) as num_students_90_plus,
round(avg(b.score),2) as avg_score_90_plus,
c.name as physics_teacher
from students a
join scores b on a.student_id = b.student_id
join teachers c on c.class_code likeCONCAT('%', a.class_code, '%')
where b.exam_date = '2024-06-30'
		and b.subject = '物理'
and b.score >= 90
group by a.class_code,c.name
order by avg_score_90_plus desc;
2026-03-01 数学成绩分段统计(1) 
SELECT 
CASE 
WHEN sc.score >= 110 THEN '[110, 120]'
WHEN sc.score >= 90 THEN '[90, 110)'
WHEN sc.score >= 60 THEN '[60, 90)'
ELSE '[0, 60)'
END AS score_range,
COUNT(*) AS num_students
FROM 
students s
INNER JOIN
scores sc ON s.student_id = sc.student_id
WHERE 
sc.subject = '数学' 
AND sc.exam_date = '2024-06-30'
GROUP BY 
score_range
ORDER BY 
CASE score_range 
WHEN '[110, 120]' THEN 4
WHEN '[90, 110)' THEN 3
WHEN '[60, 90)' THEN 2
ELSE 1
END DESC;