Skip to content

Commit

Permalink
Time: 1529 ms (49.50%), Space: 0B (100.00%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
joseantoniochacon committed Jun 4, 2024
1 parent c0be29d commit a50b7fe
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions 1251-average-selling-price/1251-average-selling-price.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Write your MySQL query statement below
SELECT prices.product_id, ROUND(IFNULL((SUM(units.units * prices.price) / SUM(units.units)),0),2) AS average_price FROM Prices prices LEFT JOIN UnitsSold units ON prices.product_id = units.product_id AND units.purchase_date BETWEEN prices.start_date AND prices.end_date GROUP BY prices.product_id;

0 comments on commit a50b7fe

Please sign in to comment.