楼主: hyper8866
跳转到指定楼层
上一主题 下一主题
收起左侧

Linkedin Data Scientist Phone Interview

🔗
dongqi221 2018-7-13 22:59:22 | 只看该作者
全局:
同问,现在秋招就开始了吗
回复

使用道具 举报

🔗
getdreamoffer 2018-7-15 09:36:02 | 只看该作者
全局:
感谢楼主分享!请问楼主用R怎么写啊?
回复

使用道具 举报

🔗
Ryohka 2018-7-15 09:48:01 | 只看该作者
全局:
现在的Phone interview都要写代码的吗……直接把代码读给对方?
回复

使用道具 举报

🔗
hellomirro 2018-7-15 22:00:16 | 只看该作者
全局:
SQL management studio

with A as (
select date, member_id, count(distinct channel) as dist_channel
from table1
group by date, member_id),

B as (
select a.date, a.member_id, t.channel, t.spend, a.dist_channel from
(select * from table1)  as t
left join
(select * from A) as a
on t.date = a.date and t.member_id = a.member_id),
..
C as (
select date, case when dist_channel = 2 then 'both' else channel end as channel, spend
from B )

select date, channel, sum(spend) as total_spend, count(*) as total_member from C
group by date, channel.1point3acres
order by date, channel
回复

使用道具 举报

🔗
 楼主| hyper8866 2018-7-16 12:32:21 | 只看该作者
全局:
Ryohka 发表于 2018-7-15 09:48
现在的Phone interview都要写代码的吗……直接把代码读给对方?
. Waral dи,
有网页codepad,一边打电话一边写代码
回复

使用道具 举报

🔗
Ryohka 2018-7-16 12:53:58 | 只看该作者
全局:
hyper8866 发表于 2018-7-16 12:32
有网页codepad,一边打电话一边写代码

哦这样还好……
我前一阵接了个电面让我口述代码我直接懵了……
回复

使用道具 举报

🔗
solasistim 2018-7-31 03:53:18 | 只看该作者
全局:
先用self join找出每天both的users:.
with both_users as
(select *
. 1point 3 acresfrom table t1 join table t2. Χ
on t1.member_id= t2.member_id. 1point3acres
and t1.date= t2.date
and t1.channel='mobile' and t2.channel='desktop'),

both_sum as.--
(select date, 'both' as channel,  sum(t1.spend+ t2.spend) as total_spend, count(distinct t1.member_id) as total_members
from both_users
group by date)

select date, channel,  sum(spend) as total_spend, sum(distinct member_id) as total_members
from table
where (date, member_id) not in
(select t1.date, t1.member_id from both_users)
group by date
union
select *
from both_sum

不确定对不对,求大神指点0.0
回复

使用道具 举报

🔗
lyp321 2018-10-7 05:33:50 | 只看该作者
全局:
Select
        date,
        case when b.channel_cnt>1 then ‘both’ else channel end as channel,
        sum(spend) as total_spend,. check 1point3acres for more.
        count(distinct a.member_id) as total_members. .и
From spending a
Join        
(Select. Χ
        memer_id,
        date,
        count(distinct channel) as channel_cnt
From spending .1point3acres
Group by 1,2) b
On a.date = b.date and a.member_id = b.member_id. check 1point3acres for more.
Group by 1,2
回复

使用道具 举报

🔗
radium 2018-11-3 04:14:26 | 只看该作者
全局:
SELECT date, channel, COALESCE(SUM(spend),0) AS total_spend, COUNT(DISTINCT member_id) AS total_members. 1point 3 acres
FROM
(
SELECT s1.member_id,
       s1.date,
       CASE WHEN s2.channel IS NULL THEN s1.channel
            ELSE 'both' END AS channel,.
       s1.spend
  FROM spending s1
  LEFT JOIN spending s2
    ON s1.member_id = s2.member_id
   AND s1.date = s2.date
   AND s1.channel != s2.channel
) a. check 1point3acres for more.
GROUP BY 1, 2
ORDER BY 1;

有一个小疑问,output里面,1/2/2018的‘both'情况没有记录,不知道怎么实现呈现这条为0的结果。
回复

使用道具 举报

🔗
powersum 2018-11-26 15:26:12 | 只看该作者
全局:
要求的output里貌似需要每天都输出3个channel,即使没有数据。如果这是硬性要求的话,应该再加一个left join列出所有日期和channel的组合:

SELECT d.date, c.channel, coalesce(total_spend, 0) as total_spend, coalesce(total_members, 0) as total_members .
FROM
(select distinct date from spending) d
cross join
(select 'both' as channel union select 'mobile' union select 'desktop') c
left join
(SELECT a.date, CASE WHEN chn_count = 2 then 'both' ELSE channel END as channel,
       sum(spend) as total_spend, count(distinct a.member_id) as total_members
FROM spending a. 1point 3acres
inner join
(SELECT member_id, date, count(distinct channel) as chn_count.
FROM spending
group by member_id, date) b
using (member_id, date)
group by date, CASE WHEN chn_count = 2 then 'both' ELSE channel END) data
using (date, channel)

抛砖引玉,求指点
回复

使用道具 举报

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

本版积分规则

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