📣 独立日限时特惠: VIP通行证立减$68
回复: 5
跳转到指定楼层
上一主题 下一主题
收起左侧

FB SMB Analyst电面

全局:

2017(10-12月) 分析|数据科学类 硕士 全职@meta - 猎头 - 技术电面  | | Pass | 在职跳槽

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
技术面是和HM直接面,统计和product/business题目根版上其他SMB面经很接近了SQL题不同,不
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
r_id, friend_id, common_songs}



上一篇:求HomeDepot-Black Lotus, Data Scientist面经
下一篇:脸书 SMB analyst 第一轮初筛
推荐
fangxiaofang 2017-12-14 04:56:26 | 只看该作者
全局:
谢谢楼主分享~~我写了一下:

drop table if exists Table1;
drop table if exists Table2;
create table Table1(
  user_id int,
  song_id int
);. 1point3acres
create table Table2(
  user_id int,
  friend_id int
);

insert into Table1 values(1, 1);
insert into Table1 values(1, 2);
insert into Table1 values(1, 3);
insert into Table1 values(1, 4);
insert into Table1 values(1, 5);
-baidu 1point3acresinsert into Table1 values(2, 1);
insert into Table1 values(2, 2);
insert into Table1 values(2, 6);
insert into Table1 values(4, 6); ..
insert into Table1 values(4, 7);
insert into Table1 values(4, 8);
insert into Table1 values(5, 1);
insert into Table1 values(5, 6);.1point3acres

insert into Table2 values(1, 2);.
insert into Table2 values(1, 3);
insert into Table2 values(1, 4);
insert into Table2 values(2, 3);. 1point 3 acres
insert into Table2 values(2, 4);
insert into Table2 values(2, 5);. 1point3acres.com
insert into Table2 values(3, 5);
insert into Table2 values(4, 5);

select user_id, friend_id, count(song_id) as common_songs
from
(select t2.user_id, t2.friend_id as friend_id, t3.song_id. 1point3acres
from Table1 t1.google  и
right join Table2 t2
on t1.user_id=t2.user_id
left join Table1 t3
on t2.friend_id=t3.user_id
and t1.song_id=t3.song_id) t
group by user_id, friend_id;

得到的output:
user_id,friend_id,common_songs
1,2,2
1,3,0
2,3,0
1,4,0
2,4,1
2,5,2
3,5,0
4,5,1
回复

使用道具 举报

🔗
ds_app2018 2018-2-19 13:07:20 | 只看该作者
全局:
another way to solve:
select distinct table2.user_id, friend_id,  sum( case when t1.song_id=t3.song_id then 1 else 0 end) as num_common

from table2
left join table1 t1 on table2.user_id=t1.user_id
left join table1 t3 on table2.friend_id=t3.user_id

group by table2.user_id, friend_id
回复

使用道具 举报

🔗
n0thing233 2018-2-27 07:54:41 | 只看该作者
全局:
Select b.user_id,b.friend_id, sum(case when a.song_id in (select  c.song_id from table1 as c where c.user_id = b.user_id) then 1  else 0 end) 'common_songs'
from table1  as a right  join table2 as b on b.friend_id = a.user_id
回复

使用道具 举报

🔗
n0thing233 2018-2-27 08:02:10 | 只看该作者
全局:
忽略楼上:
. 1point 3acres
Select b.user_id,b.friend_id, sum(case when a.song_id in (select  c.song_id from table1 as c where c.user_id = b.user_id) then 1  else 0 end) 'common_songs'
from table1  as a right  join table2 as b on b.friend_id = a.user_id
group by  b.user_id, b.friend_id
回复

使用道具 举报

无效楼层,该帖已经被删除
无效楼层,该帖已经被删除
全局:
select t3.user_id,t3.friend_id, sum(case when t3.song_id = t3.friend_song then 1 else 0) as common_song
from (
select user_id, friend_id,song_id,
(select song_id from table t2 join table t1 on t1.friend_id = t2.user_id)
as friend_song
from table t1
) t3

补充内容 (2018-4-27 05:04):
group by t3.user_id
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表