本文主要是介绍力扣(leetcode)1121和1251题(MySQL),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1121.查询结果的质量和占比
题目链接:1121.查询结果的质量和占比
解答
# Write your MySQL query statement below
select query_name,
round(avg(rating/position),2) as quality,
round(100*avg(rating<3),2) as poor_query_percentage
from Queries group by query_name
having query_name is not null;
1251.平均售价
题目链接:1251.平均售价
解答
select p.product_id,
round(ifnull(sum(price*units)/sum(units),0),2) as average_price
from Prices p left join UnitsSold u on p.product_id = u.product_id
where u.purchase_date between p.start_date and p.end_date
or u.product_id is null group by p.product_id;
最后,我写了一篇MySQL教程,里面详细的介绍了MySQL的基本概念以及操作指令等内容,欢迎阅读!
MySQL数据库万字保姆级教程
这篇关于力扣(leetcode)1121和1251题(MySQL)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!