题目:1978. 上级经理已离职的公司员工
题解:
select employee_id from Employees
where salary<30000 and manager_id is not null and manager_id not in (
select distinct employee_id from Employees
)
order by employee_id
题目:626. 换座位
题解:
select if(id%2=0,
id-1,
if( id=(select count(distinct id) from Seat),
id,
id+1)) id, student
from Seat
order by id
题目:1341. 电影评分
题解:
(
select t2.name results
from MovieRating t1 left join Users t2
on t1.user_id=t2.user_id
group by t1.user_id
order by count(*) desc,t2.name asc
limit 1
)
union all
(
select t2.title results from
MovieRating t1 left join Movies t2
on t1.movie_id =t2.movie_id
where t1.created_at>='2020-02-01' and t1.created_at<='2020-02-29'
group by t1.movie_id
order by avg(t1.rating) desc,t2.title asc
limit 1
)