携程数分笔试
澄清:赛码没问题,是我的代码问题,我习惯在开头写个注释,阐述一下题目,是我注释的问题导致我通过率为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;
