携程数分笔试

给我整无语了,两道SQL加起来90分了,算法就10分,关键是SQL死活过不了,麻烦各位大神帮忙看一下有什么玩意
1.
select Sno,Sname,count(distinct if(score < 60 ,Cno,null)) as failedCounts
from tb_grade
group by Sname,Sno
having count(distinct if(score < 60 ,Cno,null)) >= 2
order by Sno desc
这是最开始写的,后来改成了子查询,没用if,全通过了,也不知道这段代码问题出在哪
2.
select dept_sal.pay_month,department_id,dept_avg_sal,corp_avg_sal,
case when dept_avg_sal - corp_avg_sal < 0 then "lower"     
when dept_avg_sal > corp_avg_sal then "higher"     
else "same" end as comparison 
from (
    select b.department_id,substr(pay_date,1,7) as pay_month,round(avg(amount),1) as dept_avg_sal 
    from salary a 
    inner join employee b on a.employee_id = b.employee_id 
    group by b.department_id,substr(pay_date,1,7)) dept_sal 
inner join 
( 
    select substr(pay_date,1,7) as pay_month,round(avg(amount),11) as corp_avg_sal 
    from salary 
    group by substr(pay_date,1,7)) corp_sal 
on dept_sal.pay_month = corp_sal.pay_month 
order by pay_month,department_id
在本地运行结果是对的,结果怎么都过不了,好生气
#携程笔试##携程##数据分析师##笔经#
全部评论
sorry打错字了…麻烦各位大神帮忙看一下有什么问题
点赞 回复
分享
发布于 2021-09-09 21:08
是不是平均工资的精度的问题?
点赞 回复
分享
发布于 2021-09-09 21:09
乐元素
校招火热招聘中
官网直投
平均工资精度怎么调整呢?
点赞 回复
分享
发布于 2021-09-09 21:10
不应该left join吗?()
点赞 回复
分享
发布于 2021-09-09 21:13
我觉得就是corp_avg_sal的精度问题,我本地能过,但是只保留四位小数
点赞 回复
分享
发布于 2021-09-09 21:16
请问楼主投的哪里的
点赞 回复
分享
发布于 2021-09-10 09:06
第二题我ac了,不是小数点的问题应该,他那个系统用的是SQLite,所以时间转换的函数不是date_format 而是strftime
点赞 回复
分享
发布于 2021-09-10 10:06
总感觉第三题有问题😓 调整了精度也ac不了
点赞 回复
分享
发布于 2021-09-13 20:22
请问是商业数据分析岗吗
点赞 回复
分享
发布于 2022-03-02 22:56
请问python是啥类型的题呀,数据结构吗
点赞 回复
分享
发布于 2022-03-08 20:19
请问楼主还记得笔试题目是什么吗
点赞 回复
分享
发布于 2022-03-09 09:46

相关推荐

7 30 评论
分享
牛客网
牛客企业服务