新浪数据分析笔试编程第三题AC分享
我最后提交的代码AC了,但是没有复制下来,这是中途在IDE写的,也修改了下,仅供参考。
select temp1.channel_type,round( (temp1.avgRead-temp2.avgRead)*1.0/temp2.avgRead,4) as escalate
from (select channel_type,count(newsid)*1.0 / count(distinct A.uid) as avgRead
from user_read as A join new_user_info as B
on A.uid = B.uid
where new_dt = '2018-07-08' and dt = '20180708'
group by channel_type) as temp1
join
(select channel_type,count(newsid)*1.0 / count(distinct A.uid) as avgRead
from user_read as A join new_user_info as B
on A.uid = B.uid
where new_dt = '2018-07-07' and dt = '20180707'
group by channel_type) as temp2 on temp1.channel_type = temp2.channel.type
order by escalate