I have solved the task of
Delete the companies that made the least number of flights.
This is my source code -it's "arrow antipattern" , what is more elegant solution?
the inner most counts num of flights and groups by company, this is used to compare and find the actual minimum, then just select company names and delete.
DELETE FROM company WHERE name IN (SELECT name FROM (SELECT name FROM trip INNER JOIN company ON trip.company = company.id GROUP BY name HAVING Count(trip.id) = (SELECT Min(kolv) AS mini FROM (SELECT Count(trip.id) AS kolv FROM trip INNER JOIN company ON trip.company = company.id GROUP BY name ORDER BY kolv)k)) o)