题目链接: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.平均售价
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数据库万字保姆级教程