select
s.name,
s.class_code,
s.grade_code,
t.name as head_teacher_name
from students s
join teachers t on s.class_code = t.head_teacher
order by
s.student_id
select
city,
sum(if(con like '%多云%',1,0)) as cloudy_days,
concat(cast(sum(if(con like '%多云%',1,0))/count(1)*100 as decimal(4,2)),'%')as '占比'
from weather_rcd_china
where year(dt) = 2021
group by
city
order by cloudy_days desc
select
city,
sum(if(con like '%多云%',1,0)) as cloudy_days,
concat(cast(sum(if(con like '%多云%',1,0))/count(1) as decimal(4,2)),'%')as '占比'
from weather_rcd_china
where year(dt) = 2021
group by
city
order by cloudy_days
select
city,
sum(if(con like '%多云%',1,0)) as cloudy_days,
concat(cast(sum(if(con like '%多云%',1,0))/count(1) as decimal(4,2)),'%')as '占比'
from weather_rcd_china
where year(dt) = 2021
group by
city
select
case
when mch_nm like '%按摩保健休闲%' then '按摩保健休闲'
whenlower(mch_nm) rlike '.*(按摩|保健|休闲|养生|spa|会所).*' then '按摩、保健、休闲、养生、SPA、会所'
end as reg_rules,
count(distinct mch_nm)
from cmb_usr_trx_rcd
where
lower(mch_nm) rlike '.*(按摩|保健|休闲|养生|spa|会所).*' or
mch_nm like '%按摩保健休闲%'
group by
reg_rules
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')
order by trx_time