新浪数据分析笔试题讨论

1.第一题,求7.10,7.11的不同类型的渠道类型的人均观看次数和涨幅(结果第一列:渠道类型,第二列:人均观看次数,第三列涨幅)
题目有两张表

我写的答案很复杂(没有通过):这里求一个大家第一题的分享,并且麻烦大家看看错处。

select p2.*,p7.growth

from

(select p1.channel_type,count(p1.uid)/count(distinct p1.uid)

from(select n.uid,n.channel_type,u.date,u.vid,u.tag

from new_user_info as n left join user_video as u

on n.uid=u.uid) as p1

where p1.date in ('20180710','20180711')

group by p1.channel_type) as p2

inner join

(select p4.channel_type,(p6.mean2-p4.mean1)/p4.mean1 as growth

from

(select p3.channel_type,count(p3.uid)/count(distinct p3.uid) as mean1

from(select n.uid,n.channel_type,u.date,u.vid,u.tag

from new_user_info as n left join user_video as u

on n.uid=u.uid) as p3

where p3.date = '20180710'

group by p3.channel_type) as p4

inner join

(select p5.channel_type,count(p5.uid)/count(distinct p5.uid) as mean2

from(select n.uid,n.channel_type,u.date,u.vid,u.tag

from new_user_info as n left join user_video as u

on n.uid=u.uid) as p5

where p5.date = '20180711'

group by p5.channel_type) as p6

on p4.channel_type=p6..channel_type

) as p7

on p2.channel_type=p7.channel_type;
2.


我写的代码还是没有通过😥,麻烦大家看一看我代码的问题,也求大家的答案

select p1.uid

from

(select v.*,i.gender,i.age

from user_video v left join user_info i

on v.uid=i.uid) as p1

where p1.gender=''

and p1.age<=25

and p1.tag='美食'

and p1.date in ('20190801','20190802','20190803','20190804','20190805','20190806','20190807')

group by p1.uid

having count(*)>10

except

select p2.uid

from

(select v.*,i.gender,i.age

from user_video v left join user_info i

on v.uid=i.uid) as p2

where p2.gender=''

and p2.age<=25

and p2.tag='美食'

and p2.date ='20190808'

group by p2.uid

having count(*)<3;

3.第三题求不同频道观看最多的人和观看最少的人之间观看的次数差距
答案:(通过)

select p.tag,max(p.fre)-min(p.fre)

from

(select tag,uid,count(*) as fre

from user_video

group by tag,uid) p

group by p.tag;



#新浪##笔试题目##数据分析师##题解##笔经#
全部评论
第二题直接用一个聚合函数就好了。
1 回复 分享
发布于 2021-08-18 11:44
怎么我的第三题题目跟你不一样 我的里面没有说观看最多的人和观看最少的人之间观看的次数  难道是我看花了眼?
点赞 回复 分享
发布于 2019-08-31 18:09

相关推荐

蚂蚁 基架java (n+6)*16 签字费若干
点赞 评论 收藏
分享
10-17 12:16
同济大学 Java
7182oat:快快放弃了然后发给我,然后让我也泡他七天最后再拒掉,狠狠羞辱他一把😋
点赞 评论 收藏
分享
2 54 评论
分享
牛客网
牛客企业服务