Skip to content

Commit e01c946

Browse files
committed
aggregation fnuction
1 parent d6d10b6 commit e01c946

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Write your MySQL query statement below
2+
SELECT p.product_id, IFNULL(ROUND(SUM(units*price)/SUM(units),2),0) AS average_price
3+
FROM Prices p LEFT JOIN UnitsSold u
4+
ON p.product_id = u.product_id AND
5+
u.purchase_date BETWEEN start_date AND end_date
6+
group by product_id

0 commit comments

Comments
 (0)