Show me the id of products that have been booked.
select distinct product_id from products_booked
Show me their maximum booked amount.
select product_id, max(booked_amount) from products_booked group by product_id
Give me the id of those which has been booked with amount higher than 200.
select product_id from products_booked where booked_amount > 200
What about the id of products which are not one of those?
select product_id from products_for_hire where product_id not in ( select product_id from products_booked where booked_amount > 200)
How many are there?
select count(*) from products_for_hire where product_id not in ( select product_id from products_booked where booked_amount > 200 )