摘要: https://leetcode.com/articles/friend-requests-i-overall-acceptance-rate/ The divisor (total number of requests) could be '0' if the table friend_reque 阅读全文
posted @ 2018-10-22 10:34 ffeng0312 阅读(330) 评论(0) 推荐(0)
摘要: SELECT question_id FROM [survey_log] group by question_id order by sum(case when action = 'answer' then 1 end)/cast(sum(case when action = 'show' then 阅读全文
posted @ 2018-10-22 10:02 ffeng0312 阅读(196) 评论(0) 推荐(0)
摘要: select a.name from candidate a inner join ( select candidateid, count(*) no_of_votes from vote group by candidateid order by no_of_votes desc limit 1) 阅读全文
posted @ 2018-10-22 09:55 ffeng0312 阅读(170) 评论(0) 推荐(0)
摘要: select avg(id) from ( SELECT n1.id,(sum(n2.frequency)-n2.frequency) as left,sum(n2.frequency) as right FROM [number] n1, number n2 where n2.id <= n1.i 阅读全文
posted @ 2018-10-22 09:54 ffeng0312 阅读(332) 评论(0) 推荐(0)
摘要: select ranking.id, ranking.company, ranking.salary,ranking.rank,cnt FROM ( SELECT e1.id,e1.company,e1.salary,count(*) rank FROM [employee569] e1, (sel 阅读全文
posted @ 2018-10-22 09:52 ffeng0312 阅读(340) 评论(0) 推荐(0)
摘要: All leetcode sql solution: https://datageekinme.github.io/portfolio/zepl-0005/ select e1.Name from [Employee] e1 inner join ( SELECT ManagerId FROM [E 阅读全文
posted @ 2018-10-22 09:51 ffeng0312 阅读(162) 评论(0) 推荐(0)
摘要: https://leetcode.com/articles/customer-placing-the-largest-number-of-orders/ --It can handle the case where more than one customer can have maximum nu 阅读全文
posted @ 2018-10-20 06:59 ffeng0312 阅读(217) 评论(0) 推荐(0)
摘要: https://leetcode.com/articles/investments-in-2016/ select sum(i1.tiv_2016) from insurance i1 where i1.tiv_2015 in (select t2.tiv_2015 from insurance i 阅读全文
posted @ 2018-10-20 06:43 ffeng0312 阅读(268) 评论(0) 推荐(0)
摘要: https://leetcode.com/articles/find-customer-referee/ select name from customer where referee_id <> 2 or referee_id is null; MySQL uses three-valued lo 阅读全文
posted @ 2018-10-20 06:08 ffeng0312 阅读(231) 评论(0) 推荐(0)
摘要: https://leetcode.com/articles/count-student-number-in-departments/ select d.dept_name dept_name,count(s.student_id) student_number from department d l 阅读全文
posted @ 2018-10-20 06:04 ffeng0312 阅读(256) 评论(0) 推荐(0)