Check out the Query Tree Editor demos

Query Tree Editor demo - Query Editor shows the sql editor.

Query Tree Editor demo - Dependencies shows how to build a complex query with subqueries and how the tree shows the dependency between all queries. You can edit a query starting on that tree.

Query Tree Editor demo - New Query shows how to make a new query min freight cost for each customer.