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

有小伙伴一起刷SQL吗?

🔗
Fishsh 2018-8-30 23:46:56 | 只看该作者
全局:
I am using Hackerrank now.  
Yesterday Finished
   Basic Select
   Advanced Select
   Aggregation
Working on Join today!

Maybe I should use Leetcode too? So we will be on the same page.

Sorry no Chinese on my laptop.....
回复

使用道具 举报

🔗
yanyi869 2018-8-31 06:13:42 | 只看该作者
全局:
一起讨论下这道题?https://www.hackerrank.com/challenges/challenges/problem.1point3acres

我的思路是用union
第一部分:找到所有count数相同但是hacker_id不同的hacker_id 排除掉
然后union: count数等于max(count) 的. 1point 3 acres

现在写得第一部分:
select h.hacker_id, h.name, count(h.hacker_id)

from hackers h left join challenges c on h.hacker_id=c.hacker_id
. From 1point 3acres bbs
where h.hacker_id not in
(
select t1.hacker_id
   
    from (select hacker_id, count(hacker_id) as count from  challenges group by hacker_id) t1, (select hacker_id, count(hacker_id) as count from  challenges group by hacker_id) t2
    where t1.hacker_id!=t2.hacker_id and t1.count=t2.count
)
group by h.hacker_id,h.name. Χ
order by count(h.hacker_id) desc

这半部分的结果就不太对 这里返回的应该都是count数不同的 但是count为1的返回了很多 (其他count没有) 不知道小伙伴们有没有什么见解?
回复

使用道具 举报

🔗
鲁鲁飞 2018-8-31 11:51:05 | 只看该作者
全局:
kenuo 发表于 2018-8-28 22:59. .и
地里有人总结过FB和Linkedin的sql题目, 不知道楼主有兴趣么?

感觉很有用的资料!!不知道能不能给个链接分享下呢?一起刷题!~ 谢谢!!
回复

使用道具 举报

🔗
鲁鲁飞 2018-8-31 11:52:20 | 只看该作者
全局:
报名+1 一起刷~
回复

使用道具 举报

🔗
管理元 2018-9-1 03:03:53 | 只看该作者
全局:
yanyi869 发表于 2018-8-31 06:13
一起讨论下这道题?https://www.hackerrank.com/challenges/challenges/problem

我的思路是用union
. ----
这个我昨天看了  没做出来
回复

使用道具 举报

🔗
管理元 2018-9-1 03:04:16 | 只看该作者
全局:
kenuo 发表于 2018-9-1 02:21
我就是在数科面经版搜到的,你翻一下前几页应该就能看到了

好的 多谢啦~
回复

使用道具 举报

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

本版积分规则

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