PostgreSQL subqueries allow one SQL query to run inside another, making it possible to solve filtering, aggregation, ...
Don't be afraid of using your chosen database's command-line client. I might as well say this up front: I don't like using GUI (aka non-command-line or graphical) tools with my databases. This is ...