文章目录
-
- 原题题目
- 代码实现(首刷自解)
原题题目
代码实现(首刷自解)
# Write your MySQL query statement below
SELECTp.product_id,ROUND(SUM(price*units) / SUM(units),2) average_price
FROMprices p INNER JOIN unitssold u on p.product_id = u.product_id
WHEREu.purchase_date >= p.start_dateand u.purchase_date <= p.end_date
GROUP BYp.product_id