select
rcv_usr_id
,sum(pkt_amt) sum_trx_amt
from
tx_red_pkt_rcd
where
year(rcv_datetime) != 1900
group by
rcv_usr_id
order by
sum_trx_amt desc
limit 10
select * from cmb_usr_trx_rcd
where
usr_id = 5201314520
and (date(trx_time) between "2024-06-08" and "2024-06-10"
or date(trx_time) between "2024-09-15" and "2024-09-17")
select * from cmb_usr_trx_rcd
where
usr_id = 5201314520
and (trx_time between "2024-06-08" and "2024-06-10"
or trx_time between "2024-09-15" and "2024-09-17")
select
exam_date
, sum(case when subject="语文" then score else 0 end) as chinese_score
, sum(case when subject="数学" then score else 0 end) as math_score
, sum(case when subject="英语" then score else 0 end) as english_score
from
scores
where
student_id = 460093
group by
exam_date
select
exam_date
, sum(case when subject="语文" then score else 0 end) as chinese_score
, sum(case when subject="数学" then score else 0 end) as math_score
, sum(case when subject="英语" then score else 0 end) as english_score
from
scores
group by
exam_date
select
student_id,
sum(case when subject in ("语文","数学","英语") then score end) total_score
from
scores
where
exam_date = "2024-06-30"
group by
student_id
having
total_score>330
select
student_id,
sum(case when subject in ("语文","数学","英语") then score end) total_score
from
scores
where
exam_date = "2024-06-30"
group by
student_id
having
total_score>=330
select
case
when enter_date >= "2010-01-01" then "青年教师"
when enter_date < "2000-01-01" then "资深教师"
else "中年教师"
end as teacher_type
, count(1) teacher_count
from
teachers
group by teacher_type
select
case
when enter_date >= "2010-01-01" then "青年教师"
when enter_date < "2000-01-01" then "青年教师"
else "中年教师"
end as teacher_type
, count(1) teacher_count
from
teachers
group by teacher_type
SELECT
student_id,
MAX(score) AS max_score,
MIN(score) AS min_score,
AVG(score) AS avg_score
FROM scores
WHERE student_id IN (460093, 735011) AND subject = '数学'
GROUP BY student_id;