A subquery can occur in the Projection clause of another
SELECT statement. The following query shows how you might use a subquery
in a Projection clause to return the total shipping charges (from
the orders table) for each customer in the customer table.
You could also write this query as a join between two tables.Figure 1: Query
SELECT customer.customer_num,
(SELECT SUM(ship_charge)
FROM orders
WHERE customer.customer_num = orders.customer_num)
AS total_ship_chg
FROM customer;