select
cust_name
,order_num
,(
select
sum(quantity*item_price)
from OrderItems o
where o.order_num = ord.order_num
group by order_num
) as OrderTotal
from Customers c
join Orders ord
using(cust_id)
order by cust_name
涉及到要查询的字段,部分需要聚合,采用标量子查询,逻辑更清晰

京公网安备 11010502036488号