题解 | 商品销售排名
商品销售排名
https://www.nowcoder.com/practice/79c6c3d6d66946f79387bca73c0a29f4
-- 各商品销售数量 with t1 as ( select product_id, sum( case when step = 'select' and pay_method is not null then 1 else 0 end ) cnt from user_client_log group by product_id ) select product_name, cast(round(price * cnt, 0) as signed) total from t1 left join product_info p on t1.product_id = p.product_id order by total desc limit 2