https://leetcode.com/problems/average-selling-price/
Account Login - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
select a.product_id, round(sum(a.price * b.units)/sum(b.units), 2) as average_price
from Prices as a
left outer join UnitsSold as b
on a.product_id = b.product_id
and b.purchase_date between a.start_date and a.end_date
group by product_id
728x90
반응형
'자료구조 알고리즘 > 코딩테스트' 카테고리의 다른 글
JadenCase 문자열 만들기 (0) | 2022.09.16 |
---|---|
최댓값과 최솟값 (0) | 2022.09.16 |
1565. Unique Orders and Customers Per Month (0) | 2022.06.24 |
1421. NPV Queries (0) | 2022.06.24 |
740. Delete and Earn (0) | 2022.06.18 |