select
student_id,sum(score) total_score
from scores
where exam_date ='2024-06-30' and subject in ('语文','数学','英语')
group by student_id
having total_score>330
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
select
student_id,
max(score) max_score,
min(score) min_score,
avg(score) avg_score
from scores
group by student_id
having avg_score >=80
order by student_id
select
student_id,
max(score) max_score,
min(score) min_score,
sum(score)/count(score) avg_score
from scores
group by student_id
having avg_score >=80
order by student_id
select
city,
sum(case
when con regexp '多云' then 1
else 0
end
) cloudy_days,
concat(
cast(
sum(
case
when con regexp '多云' then 1
else 0
end
)/count(1)
*100
as decimal(10,2)
),
'%'
)p
from weather_rcd_china
where year(dt)= 2021
group by city
select
case
when trx_amt = 288 then '1.WithHand'
when trx_amt = 388 then '2.WithMimi'
when trx_amt = 588 then '3.BlowJobbie'
when trx_amt = 888 then '4.Doi'
when trx_amt = 1288 then '5.DoubleFly'
else '6.other'
end ser_typ,
count(1) trx_cnt,
min(date(trx_time)) first_date
from cmb_usr_trx_rcd
where
usr_id = '5201314520'
and mch_nm = '红玫瑰按摩保健休闲'
group by ser_typ
order by 1
select
case
when trx_amt = 288 then '1.WithHand'
when trx_amt = 388 then '2.WithMimi'
when trx_amt = 588 then '3.BlowJobbie'
when trx_amt = 888 then '4.Doi'
when trx_amt = 1288 then '5.DoubleFly'
else '6.other'
end ser_typ,
count(1) trx_cnt,
min(trx_time) first_date
from cmb_usr_trx_rcd
where
usr_id = '5201314520'
and mch_nm = '红玫瑰按摩保健休闲'
group by ser_typ
order by 1