A subquery can occur in the projection list of another SELECT statement. Figure 300 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.
SELECT customer.customer_num, (SELECT SUM(ship_charge) FROM orders WHERE customer.customer_num = orders.customer_num) AS total_ship_chg FROM customer
customer_num total_ship_chg 101 $15.30 102 103 104 $38.00 105
·
·
·
123 $8.50 124 $12.00 125 126 $13.00 127 $18.00 128