查看: 6321| 回复: 17
跳转到指定楼层
上一主题 下一主题
收起左侧

[统计--就业] 求大米-领英-DA-SQL

 
全局:

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

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

x
前天刚收到的LinkedIn DA的SQL题,看了下地里的题目好像没有出现过,可能是我刷的不够,也可能是大家都投的full-time或者intern,我这份是contract的所以题不一样,也发上来给大家参考一下。
我在本科和master阶段都没正经学过SQL, 是找工作期间才发现不管BA,DA都是要会写SQL的,所以只好硬着头皮开始学了。在地里看了不少帖子如何自学SQL,先把W3基本过了一遍,然后leetcode上的database题过了easy和median的,前段时间在刷hackerranker。题目基本就是这么多,SQL主要还是考思路,写之前想的比较久。我本身不是天赋型选手,别人做一遍的题目我可能要做三四遍才能记住,可能还是兴趣问题,现在来地里记录找工过程,希望能有进步。
好了,直接放题,也不设置积分权限,就求一点大米~~.--

Tables:
Payment Table: This table contains all the payment records on a date and member level. This is for members who make a payment on each day. A sample data looks like this:
Date
memberID
Amount
1/3
A
$33.9
1/4
C
$19.3
1/7
A
$29.1


User Table: This table contains all the active records on a date and member level. This is for member who visit linkedin.com site on each day. A sample data looks like this:
Date
memberID
1/1
A
1/3
A
1/3
B
1/4
A
1/4
C
1/5
B

. From 1point 3acres bbs
Date Table: this table contains the date information
Date
1/1
1/2
1/3
1/4
1/5
1/6

.google  и
Questions:
Please write a query for the following cases:
  • 1. Total Revenue & Payers: Create a table to display total revenue & number of buyers on each day
Date
revenue
buyers


  • 2. Top payers: Create a table to display the top one payer on each day
Date
memberID
.1point3acres

  • 3. A distribution of # days active within a week: Create a table to show how many members are active for 1 day, 2days, 3days,…7days during 3/1-3/7.
#Days Active
Count
1

2

3

4

5

6

7


  • 4. Active but not payers: Create a table to display people who were active but did not pay on each day
Date
memberID


评分

参与人数 20大米 +32 收起 理由
kkkkkkkkkchen + 1 很有用的信息!
wnzcm + 1 很有用的信息!
starzero + 2 给你点个赞!
情书青色珊瑚礁 + 1 给你点个赞!
godeyes + 2 很有用的信息!

查看全部评分


上一篇:关于暑期科研申请
下一篇:请问有面过logDNA的吗?
推荐
 楼主| Jessica028 2019-2-2 03:40:20 | 只看该作者
全局:
3.         SELECT #Days Active, COUNT(*)
            FROM (SELECT DISTINCT memberID, COUNT(*) as #Days Active
                          FROM user
                          WHERE date>=‘3/1’ AND date <= ‘3/7’ ..
                          GROUP BY memberID) sub. From 1point 3acres bbs
            GROUP BY #Days Active
            ORDER BY #Days Active ..
回复

使用道具 举报

全局:
# q1 with t1 as (select date, sum(amount) as revenue from payment group by 1) t2 as (select date, count(distinct memberid) as num_users from user group by 1) select date.date, t1.revenue,t2.buyers from date left join t2 on date.date=t2.date left join t1 on t1.date=date.date  # q2 select date,memberid from( select date, memberid,rank() over(partition by date,memberid order by sum(amount) desc) as rank from payment) where rank = 1   # q3 with t as ( select member, count(distinct date) as active_days from user where date <= 2019-03-07 and date >= 2019-03-01 group by 1) select count(member), active_days from t group by 2 order by 2  # q4  select u.date,u.memberid from user u left join payment p where u.date=p.date and u.memberid<>p.memberid
回复

使用道具 举报

🔗
 楼主| Jessica028 2019-2-2 03:38:49 | 只看该作者
全局:
答案在这里:-baidu 1point3acres
1. SELECT SUM(amount) revenue, COUNT(DISTINCT memberID) buyers, date
    FROM payment
    GROUP BY date
回复

使用道具 举报

🔗
 楼主| Jessica028 2019-2-2 03:40:00 | 只看该作者
全局:
2.
With a as(. 1point 3 acres
SELECT date, memberID, SUM(amount) as Samount, rank () over (partition by date
ORDER BY SUM(amount) DESC) as rank
FROM payment.google  и
GROUP BY date, memberID)
SELECT date, memberID
FROM a
WHERE rank = 1
回复

使用道具 举报

🔗
 楼主| Jessica028 2019-2-2 03:40:43 | 只看该作者
全局:
4.          SELECT u.date, u.memberID
             FROM user u
             LEFT JOIN payment p ON u.date = p.date AND u.memberID = p.memberID
             WHERE Amount is NULL ORDER BY u.date
回复

使用道具 举报

🔗
ShihaoYing 2019-2-16 14:25:10 | 只看该作者
全局:
楼主后续面试了么? 想问一下情况
回复

使用道具 举报

🔗
nicholassssss 2019-2-19 09:08:42 | 只看该作者
全局:
同问楼主后续,感谢~
回复

使用道具 举报

🔗
xixihahaha 2019-2-21 13:27:17 | 只看该作者
全局:
感谢分享,想问楼主是怎么找到contract的机会的呢?
回复

使用道具 举报

🔗
 楼主| Jessica028 2019-2-21 16:37:16 来自APP | 只看该作者
全局:
ShihaoYing 发表于 2019/02/16 14:25:10
楼主后续面试了么? 想问一下情况
.--
没有后续…
回复

使用道具 举报

🔗
 楼主| Jessica028 2019-2-21 16:37:48 来自APP | 只看该作者
全局:
xixihahaha 发表于 2019/02/21 13:27:17
. .и感谢分享,想问楼主是怎么找到contract的机会的呢?
.1point3acres
是recruiter联系我的,但是并没有后续
回复

使用道具 举报

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

本版积分规则

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