注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
面试挂了,虽然自我感觉准备的挺充分,但还是没有把面经给吃透。求积分想看更多的帖子
Take away
1. 面经真的很重要,把面经看懂了,能给不懂的人说,最好自己create 一个table 做一下,面试过程当中还是会有follow up question的2. 虽然可以clarify,但对对方问题的理解的准确性的理解也很重要,我在clarify上花了挺久时间的。 还是需要多模拟一下面试。
同时招募在职小伙伴一起互相mock interview 转data scientist analytics track。能够commit 的请发邮件 bloominglife08@gmail.com. .и
3. code clean,performance 都很重要
4. 准备的过程,觉得leet code 的题和面试的时候还是不大一样,觉得FB 的面试sql题和真题更加接近。可以刷完leetcode 写FB. .и
一个ask, 大家有看到用set variable 之类的sql 题么?
. ----Question1: .google и
table name: ps (play sessions)
one row is one session
country | duration (s)
US 600. 1point3acres
US 300
JP 1800
US 75
. From 1point 3acres bbs
### 1. Write a query that returns the average duration of sessions longer than 30 mins
select avg(duration). 1point3acres
from ps
where duration > 1800;
### 2. top 5 countries with highest total duration (ask rank, window function)
with sessions as
(select country, sum(duration) as session
from ps)
select country
from (-baidu 1point3acres
. 1point3acres
select country, rank() over (order by session) as rank
from ps) tbl
where rank ≤ 5
order by rank;
### 3. write a query that return data for a histogram of play sessions in 5 mins
. ----
bin | sessions
. ----
---
0-5 200
5-10 300
10-15 600 . Waral dи,
### 4. Write a query that returns similar countries, where similar countries are defined as having within 1000 total sessions of each other
. Waral dи,
US 6000
. .и
JP 5001. ----
Result
. .иcountry_a | country_b
US JP
. 1point 3acres
JP US .--
面试官说能否用inner join,但同时输出US 和 JP. 我用了cross join 大家如果有别的解法,请留言哈。
The question asks if the duration difference between 1000 then consider them as similar countries
.google и
with agg as .
(select country, count(*) as sessions
.--
from ps
group by country)
select a.country as country_a, [b.count](http://b.country)ry as country_b
from agg a.
cross join agg b
where (a.sessions - b.sessions) <1000 and [a.country](http://a.country) <> [b.country](http://b.country)
|