set @rank:=0;
select "huya" as PT, T1.game_name, T1.profileRoom, T2.totalCount, T3.DM from (
select count(DISTINCT profileRoom) as profileRoom,game_name from huyaLiveInfo where date_format(insert_date, '%Y-%m-%d') = "2022-01-24" group by game_name
) T1
LEFT JOIN(
select game_name, sum(totalCount) as totalCount from(
select *,@rank:=case when @current_id<>profileRoom then 1 else @rank+1 end as rank,@current_id:=profileRoom
from huyaLiveInfo where date_format(insert_date, '%Y-%m-%d') = "2022-01-22"
order by totalCount desc
) a
where a.rank = 1
group by a.game_name
) T2
on T1.game_name = T2.game_name
LEFT JOIN(
select count(*) as DM, game_name from huyaLiveDanMu_copy where date_format(insert_date, '%Y-%m-%d') = "2022-01-24" group by game_name
) T3
on T3.game_name = T2.game_name