SELECT
t2.live_id,
t2.live_nm,
count(distinct usr_id) as cnt
from ks_live_t1 as t1 join ks_live_t2 as t2 on t1.live_id = t2.live_id
where date_format(t1.enter_time,'%Y-%m-%d %H') = '2021-09-12 23'
group by 1,2
order by cnt desc
limit 5;
select
sum(case when right(card1,1)=right(card2,1) then 1 else 0 end)/2 as cnt
, count(1)/2 as ttl_cnt
,cast(sum(case when right(card1,1)=right(card2,1) then 1 else 0 end)/count(1) AS DECIMAL(4,3)) as p
from hand_permutations
select
cast(sum(case when right(card1,1) = right(card2,1) then 1 else 0 end) / 2 as decimal(3,0)) as cnt,
cast(count(1)/2 as decimal(4,0)) as ttl_cnt ,
cast(sum(case when right(card1,1)=right(card2,1) then 1 else 0 end)/count(1) AS DECIMAL(4,3)) as p
from hand_permutations;
select
cast(sum(case when right(card1,1) = right(card2,1) then 1 else 0 end) / 2 as decimal(3,0)) as cnt,
cast(count(1)/2 as decimal(4,0)) as ttl_cnt ,
cast(sum(case when right(card1,1) = right(card2,1) then 1 else 0 end) / count(1) as decimal(4,3)) as p
from hand_permutations;
select
cast(sum(case when right(card1,1) = right(card2,1) then 1 else 0 end) / 2 as decimal(3,0)) as cnt,
cast(count(1)/2 as decimal(4,0)) as ttl_cnt ,
sum(case when right(card1,1) = right(card2,1) then 1 else 0 end) / count(1) as p
from hand_permutations;
select
cast(sum(case when right(card1,1) = right(card2,1) then 1 else 0 end) / 2 as decimal(3,0)) as cnt,
count(1)/2 as ttl_cnt,
sum(case when right(card1,1) = right(card2,1) then 1 else 0 end) / count(1) as p
from hand_permutations;
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) * 100 / count(1) as decimal (10,2)),'%') as p
from weather_rcd_china
where year(dt) = 2021
group by 1
order by 2 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) * 100 / count(1) as decimal (5,2)),'%') as p
from weather_rcd_china
where year(dt) = 2021
group by 1
order by 2 desc;