select cust_name ,t2.order_num ,sum(quantity * item_price) as OrderTotal /*窗口函数往往适用于明细与汇总,只保留一条总计的用group by*/ from Customers t1 join Orders t2 on t1.cust_id = t2.cust_id join OrderItems t3 on t2.order_num = t3.order_num group by cust_name ,t2.order_num order by cust_name



京公网安备 11010502036488号