with q_temp as ( select p.product_id,product_name,sum(quantity) as total_quantity from products_underline p join sales_underline s on s.product_id=p.product_id group by p.product_id ) select q.product_id,product_name,total_quantity,round(avg(rating) ,2) as average_rating from q_temp q join reviews_underline r on r.product_id=q.product_id group by q.product_id having avg(rating)<4 order by average_rating,q.product_id;

京公网安备 11010502036488号