Day 23. ์ ๋(Flow)์ ์ ๋(Stock)
https://solvesql.com/problems/flow-and-stock/
select year(acquisition_date) as 'Acquisition year'
, count(artwork_id) as 'New acquisitions this year (Flow)'
, sum(count(artwork_id)) over
(order by year(acquisition_date) rows unbounded preceding) as 'Total collection size (Stock)'
from artworks
where acquisition_date is not null
group by year(acquisition_date)
โCOUNT() ํจ์์ ์๋์ฐ ํจ์ ์ฌ์ฉํด์ ๊ฐ์ ์ธ๊ธฐ
โROWS UNBOUNDED PRECEDING ์ฌ์ฉํด์ ๋์ ํฉ ๊ตฌํ๊ธฐ
โGROUP BY ์ฌ์ฉํด์ ๋
๋ ๊ธฐ์ค์ผ๋ก ๊ทธ๋ฃนํ