SQL41 确定最佳顾客的另一种方式(二)
描述
OrderItems 表代表订单信息,确定最佳顾客的另一种方式是看他们花了多少钱,OrderItems 表有订单号 order_num 和 item_price...商品售出价格、quantity 商品数量
order_num item_price quantity
a1 10 105
a2 1 1100
a2 1 200
a4 2 1121
a5 5 10
a2...) NOT NULL COMMENT '商品订单号',
item_price INT(16) NOT NULL COMMENT '售出价格',
quantity INT(16) NOT NULL COMMENT...'商品数量'
);
INSERT `OrderItems` VALUES ('a1',10,105),('a2',1,1100),('a2',1,200),('a4',2,1121),('a5',5,10...:
取别名:AS 关键字
求和:SUM()
GROUP BY 和 HAVING 同时使用用于过滤结果
排序:ORDER BY 关键字
主要考察对多个 SQL 关键字的运用,同时还需要注意 SQL 中关键字的前后顺序