新浪数据分析sql第三题通不过啊

select xx.channel_type,round(xx.cnt2-xx.cnt1,4) as cn
from
(
select x.channel_type,sum(case when x.dt='20180707' then 1 else 0 end )/count(distinct case when x.dt='20180707' then x.uid else null end) as cnt1,
sum(case when x.dt='20180708' then 1 else 0 end )/count(distinct case when x.dt='20180708' then x.uid else null end) as cnt2
from
(
select a.uid,a.channel_type,a.dt,b.newsid,b.newsarea
from
(
select uid,substr(new_dt,1,4)||substr(new_dt,6,2)||substr(new_dt,9,2) as dt,channel_type
from new_user_info
where substr(new_dt,1,4)||substr(new_dt,6,2)||substr(new_dt,9,2)>='20180707'
and substr(new_dt,1,4)||substr(new_dt,6,2)||substr(new_dt,9,2) <='20180708'
group by uid,substr(new_dt,1,4)||substr(new_dt,6,2)||substr(new_dt,9,2) ,channel_type
)a
left join
(
select dt,uid,newsid,newsarea
from user_read
where dt>='20180707'
and dt<='20180708'
)b
on a.uid=b.uid
and a.dt=b.dt
)x
group by x.channel_type
)xx
order by cn
感觉没问题啊
#新浪#
全部评论
第一句就有问题了,人家让求的是涨幅,所以还得除以7月7日的数据
点赞 回复
分享
发布于 2018-09-16 00:05
而且splite里边似乎round不能用,也可能是我写的有问题所以没过,反正看着那个提示也是一脸懵逼
点赞 回复
分享
发布于 2018-09-16 00:11
联易融
校招火热招聘中
官网直投
可以在线调试吗
点赞 回复
分享
发布于 2018-09-16 06:58
题目是啥还记得嘛?我看看?
点赞 回复
分享
发布于 2018-09-18 09:50

相关推荐

点赞 4 评论
分享
牛客网
牛客企业服务