select city,
sum(case when con like '%多云%' then 1 else 0 end) as cloudy_days,
concat(cast(sum(case when con like '%多云%' then 1 else 0 end)/count(con)*100 as decimal(10,2)), '%') as p
from weather_rcd_china
where year(dt) = '2021'
group by city
order by 3 desc
select city,
sum(case when con like '%多云%' then 1 else 0 end) as cloudy_days
,concat(cast(sum(case when con like '%多云%' then 1 else 0 end)/count(1)*100 as decimal(10,2)),'%') as p
from
weather_rcd_china
where
year(dt)=2021
group by
city
order by
3 desc
select city,
sum(case when con like '%多云%' then 1 else 0 end) as cloudy_days,
concat(cast(sum(case when con like '%多云%' then 1 else 0 end) / count(1) * 100 as decimal(10,2)), '%') as p
from weather_rcd_china
where year(dt) = '2011'
group by city
order by p desc
select city,
sum(case when con like '%多云%' then 1 else 0 end) as cloudy_days,
concat(cast(sum(case when con like '%多云%' then 1 else 0 end) / count(con) * 100 as decimal(10,2)), '%') as p
from weather_rcd_china
where year(dt) = '2011'
group by city
order by p desc
select city,
sum(case when con like '%多云%' then 1 else 0 end) as cloudy_days,
concat(cast(sum(case when con like '%多云%' then 1 else 0 end) / count(con) * 100 as decimal(4,2)), '%') as p
from weather_rcd_china
where year(dt) = '2011'
group by city
order by p desc
select city,
sum(case when con like '多云%' then 1 else 0 end) as cloudy_days,
concat(cast(sum(case when con like '多云%' then 1 else 0 end) / count(con) * 100 as decimal(4,2)), '%') as p
from weather_rcd_china
where year(dt) = '2011'
group by city
order by p desc
select
case
when mch_nm like '%按摩保健休闲%' then '按摩保健休闲'
when lower(mch_nm) rlike '按摩|\保健|\休闲|\养生|\SPA|\会所' then '按摩、保健、休闲、养生、SPA、会所'
end as reg_rules,
count(distinct mch_nm) as mch_cnt
from cmb_usr_trx_rcd
where mch_nm like '按摩保健休闲%' or lower(mch_nm) rlike '按摩|\保健|\休闲|\养生|\SPA|\会所'
group by reg_rules
select
case
when mch_nm like '%按摩保健休闲%' then '按摩保健休闲'
when lower(mch_nm) rlike '按摩|\保健|\休闲|\养生|\SPA|\会所' then '按摩、保健、休闲、养生、SPA、会所'
end as reg_rules,
count(distinct mch_nm) as mch_cnt
from cmb_usr_trx_rcd
where mch_nm like '%按摩保健休闲%' or lower(mch_nm) rlike '按摩|\保健|\休闲|\养生|\SPA|\会所'
group by reg_rules