--find each sale for each city and state based on their yearly sale, and sum them all select *, sum(sale)over(partition by yyyy) from( select city,state, extract(year from order_date ) as yyyy, sum(sales)as sale from orders_table as ot where state = 'New York' group by 1,2,3 )t1