目录
题目
准备数据
分析数据
总结
题目
找出 低质量 问题的 ID 集合。如果一个力扣问题的喜欢率(喜欢数除以总投票数)严格低于 60%
,则该问题为低质量问题。
按 problem_id
升序排列返回结果表。
准备数据
Create table If Not Exists Problems (problem_id int, likes int, dislikes int)
Truncate table Problems
insert into Problems (problem_id, likes, dislikes) values ('6', '1290', '425')
insert into Problems (problem_id, likes, dislikes) values ('11', '2677', '8659')
insert into Problems (problem_id, likes, dislikes) values ('1', '4446', '2760')
insert into Problems (problem_id, likes, dislikes) values ('7', '8569', '6086')
insert into Problems (problem_id, likes, dislikes) values ('13', '2050', '4164')
insert into Problems (problem_id, likes, dislikes) values ('10', '9002', '7446')
分析数据
select
problem_id
from problems
where (likes / (likes + dislikes)) < 0.6
order by problem_id;
总结
排序使用的函数是 order by