携程数分笔试

澄清:赛码没问题,是我的代码问题,我习惯在开头写个注释,阐述一下题目,是我注释的问题导致我通过率为0。对于其他朋友相似但没通过的代码,跟平台有没有关系,我就不知道了。

再一次被携程数据分析的赛码打败!!!
两道SQL题,九十分,一道题都过不了,终究是服了!!!
附上SQL代码:
1、
select *
from (
    select Sno, Sname,
           sum(case when score < 60 then 1 else 0 end) as fc
    from tb_grade
    group by Sno) g
where g.fc >= 2
order by g.Sno desc;
2、
select t1.month as pay_month, 
       t1.department_id, 
       t1.dept_avg_sal, 
       t2.corp_avg_sal,
       case when t1.dept_avg_sal > t2.corp_avg_sal then 'higher'
            when t1.dept_avg_sal < t2.corp_avg_sal then 'lower'
            else 'same' 
       end as comparison
from 
    (select g.month, g.department_id, 
           round(avg(g.amount), 1) as dept_avg_sal
    from (
        select amount, substr(pay_date, 1, 7) as month, e.department_id
        from salary as s left join employee as e on s.employee_id =  e.employee_id
        ) as g
    group by g.month, g.department_id) as t1
left join
    (select f.month, avg(f.amount) as corp_avg_sal
     from (
         select amount, substr(pay_date, 1, 7) as month from salary
         ) as f
     group by f.month) as t2
on t1.month = t2.month
order by t1.month, t1.department_id;

#笔试题目##携程#
全部评论
我也是!!第二题咱写的一模一样,第一题我跟你差不多但我用的if,后来实在不行我就改成了子查询😅😅😅服了服了
1 回复 分享
发布于 2021-09-09 20:54
第一个group by后面少写了一个段
2 回复 分享
发布于 2021-09-09 20:54
平台问题..也可能是sqlite的注释符号不一样..我之前有回考试也是这样弄了半个小时才发现是注释不该加😅
点赞 回复 分享
发布于 2021-09-09 22:05
楼主第二个sql题和我基本上一模一样的写法,但是我只能a67%,不知道哪里出问题了
点赞 回复 分享
发布于 2021-09-09 21:27
同本地可以跑出来,在网页考试就报错
点赞 回复 分享
发布于 2021-09-09 21:13
赛码 真的绝,第二题咱几乎一模一样也不过哈哈哈😂
点赞 回复 分享
发布于 2021-09-09 21:12
加了desc就是0
点赞 回复 分享
发布于 2021-09-09 21:11
不是一共三道题嘛。。
点赞 回复 分享
发布于 2021-09-09 21:03
第一题用count() group by...having直接过了
点赞 回复 分享
发布于 2021-09-09 20:57
第二题我一个小时正确率0(我试了好几种切割字符串的方法,看起来没有一个切好的),不过你这第一题看起来好像没啥毛病啊,我写的差不多啊,全通过,难道是字段名不一样?
点赞 回复 分享
发布于 2021-09-09 20:54
第二道我和你思路一样,我本地跑出来全对,提交就0,给我整无语了
点赞 回复 分享
发布于 2021-09-09 20:53

相关推荐

05-20 18:38
北京大学 Java
点赞 评论 收藏
分享
评论
1
20
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务