Skip to content

Commit e25ac5b

Browse files
authored
Update Average selling price.sql
1 parent 8952d5b commit e25ac5b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Easy/Average selling price.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,9 @@ on (s.product_id = u.product_id and u.purchase_date
8484
group by pid
8585

8686

87+
My sol:
88+
select p.product_id, round(sum(price*units*1.0)/sum(units),2) as average_price
89+
from UnitsSold u inner join Prices p on u.product_id = p.product_id and u.purchase_date between p.start_date and p.end_date
90+
group by p.product_id
91+
8792

0 commit comments

Comments
 (0)