Find the id of suppliers whose average amount purchased for each product is above 50000 or below 30000
select supplier_id from product_suppliers group by supplier_id having avg ( total_amount_purchased ) > 50000 or avg ( total_amount_purchased ) < 30000
Which of those suppliers purchased less than 30000?
select supplier_id from product_suppliers group by supplier_id having avg ( total_amount_purchased ) < 30000
And how much was their average amount purchased for each product?
select product_id, avg ( total_amount_purchased ) from product_suppliers group by product_id
What was their most recent date_supplied_to?
select date_supplied_to from product_suppliers order by date_supplied_to desc limit 1