前五道题:LeetCode 高频 SQL 50 题(基础版)之 【连接】部分 · 上
题目:577. 员工奖金
题解:
- select r.name,b.bonus from Employee r left join Bonus b on r.empId=b.empId
- where b.bonus <1000 or b.bonus is null
复制代码 题目:1280. 学生们参加各科测试的次数
题解:
- select stu.student_id student_id, stu.student_name student_name,sub.subject_name subject_name,
- count(ex.student_id) attended_exams
- from Students stu
- join Subjects sub
- left join Examinations ex
- on stu.student_id = ex.student_id and sub.subject_name = ex.subject_name
- group by stu.student_id ,sub.subject_name
- order by stu.student_id ,sub.subject_name
复制代码 题目:570. 至少有5名直接下属的司理
题解:
- select name from Employee
- where id in (
- select managerId from Employee
- group by managerId
- having count(managerId)>=5
- )
复制代码 题目:1934. 确认率
题解:
- select s.user_id user_id, round( ifnull(avg(c.action='confirmed'),0),2) confirmation_rate from Signups s left join Confirmations c
- on s.user_id = c.user_id
- group by s.user_id
复制代码 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
|