Your query can return values which come from another table. It is also called a SubQuery.
This can be done in two places:
If you have a SubSelect expression in an existing SQL statement, then you can amend this as folows:
AQT will parse the SubSelect and display it in the SubSelect dialog for you to amend.
The following query displays Sales Details, but includes the customers full name, which comes from the Customers table.
Select ORDERNO, ORDER_DATE, QUANTITY_ORDERED, CUSTOMER,
(SELECT FULLNAME FROM CUSTOMER_INFO WHERE CUSTOMER=s.CUSTOMER)
FROM SALES_DETAILS s
(SELECT FULLNAME FROM CUSTOMER_INFO WHERE CUSTOMER=s.CUSTOMER) is called a SubSelect clause as it selects data from another table.
Some rules about SubSelects:
In most cases, you would "join" the SubSelect to the outer table. This is done here with the clause
WHERE CUSTOMER=s.CUSTOMER. This ensures that only a single value is returned per row in the outer table. This is often called a correlated subselect (or correlated subquery) as this Where clauses correlates / matches the rows between the two tables.