leetcode-Average Selling Price

# Write your MySQL query statement below

select p.product_id,round(sum(p.price*u.units)/sum(u.units),2) as average_price from Prices p join UnitsSold u on p.product_id = u.product_id where u.purchase_date between p.start_date and p.end_date group by p.product_id

描述一下sql顺序:from->join->where->group by ->select

发布了48 篇原创文章 · 获赞 0 · 访问量 4334

猜你喜欢

转载自blog.csdn.net/weixin_41327340/article/details/103753717