Created
September 1, 2024 08:10
-
-
Save AashishNandakumar/7d644507570ba52e6ae5fdb8bbf4970b to your computer and use it in GitHub Desktop.
September 1st 2024 Questions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Write your MySQL query statement below | |
select p.product_id, ifnull(round(sum(p.price * u.units) / sum(u.units), 2), 0) as average_price | |
from Prices p left join UnitsSold u on p.product_id=u.product_id and u.purchase_date between p.start_date and p.end_date | |
group by p.product_id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment