SQL is dynamic enough to handle queries within queries. These inner queries are called subqueries and they can be used in many different sections of another query. In this video we will use subqueries within a where clause, a join statement, and as a column value.
select user_handle, sku, (select avg(quantity) from Purchases where user_handle = p.user_handle and sku = p.sku) from Purchases p group by user_handle, sku;