It gets to be a little puzzling fairly quickly
-- were any planes overweight?
select flights.flight_id, flights.max_weight, sum(passengers.weight_in_lbs)
from flights, passengers, reservations
where flights.flight_id = reservations.flight_id
and passengers.passenger_id = reservations.passenger_id
group by flights.flight_id, flights.max_weight
having sum(passengers.weight_in_lbs) > flights.max_weight;
--- who are the customers that have taken than 10 flights?
select passengers.passenger_id, count(*)
from passengers, reservations
where passengers.passenger_id = reservations.passenger_id
group by passengers.passenger_id
having count(*) > 10;