Correlated Subqueries
--Show the average painting width.
select avg(width) as avg_width from canvas.work
--Show the average painting width for each of painting
select style, avg(width) as avg_width from canvas.work group by style
--Show the average painting width for painting of the Baroque style
select avg(width) as avg_width from canvas.work where style = 'Baroque'
-- Show all information about paintings with an average width greater than 22.881 inces
select * from canvas.work where width > 22.881
-- Using a subquery, show all information about paintings with an average width greater than the average width of paintings of the Baroque style
select * from canvas.work where width > (select avg(width) as avg_width from canvas.work where style = 'Baroque')
-- Show all information about paintings with a width greater than the average of the width of painting in thier style.
average width of paintings of the Baroque style
select * from canvas.work w where width > (select avg(width) as avg_width from canvas.work k where k.style = w.style)
--Show all infomations about products with a price greater than twice that of least expensive product in thier category.
select * from hudsonu.product p where current_price >
(select min(CURRENT_PRICE)*2 as twice from hudsonu.product where category = p.category );