select
*
from
scores
where
(
(subject = "历史"and score >= 90) or
(subject = "政治"and score >= 90) or
(subject = "地理"and score >= 90)
)
and exam_date = "2024-06-30"
order by
score desc,student_id,subject
select
exam_date
,min(case when subject = "语文" then score end ) chinese_score
,min(case when subject = "数学" then score end ) math_score
,min(case when subject = "英语" then score end ) english_score
from
scores
where
student_id = "460093"
group by
exam_date
order by
exam_date
select
exam_date
,min(case when subject = "语文" then score end ) chinese_score
,min(case when subject = "数学" then score end ) math_score
,min(case when subject = "英语" then score end ) english_score
from
scores
where
student_id = "460093"
group by
exam_date
select
student_id
,sum(score) sum_score
from
scores
where
subject in ("语文","数学","英语")
and exam_date = "2024-06-30"
group by
student_id
having
sum(score) > 330
select
case when left(enter_date,4) < "2000" then "资深教师"
when left(enter_date,4) >= "2010" then "青年教师"
else "中年教师" end teacher_type
,count(1)
from
teachers
group by
teacher_type