瑛太莱一面sql
order_info | order_id | order_time | order_amount | | -------- | ------------------- | ------------ | | 5001 | 2020-07-01 23:59:59 | 52.00 | | 5002 | 2020-07-15 20:00:00 | 13.14 | | 5003 | 2020-05-04 19:11:00 | 52.10 | order_goods | order_id | goods_id | goods_num | | -------- | -------- | --------- | | 5001 | 1002 | 2 | | 5001 | 1000 | 8 | | 5002 | 1006 | 6 | | 5002 | 1001 | 5 | | 5003 | 1000 | 5 | 请写sql求出2020年7月订单的商品总件数 select COUNT(g.goods_num) from order_goods g left jion order_info i on g.order_id = i.order_id where g.order_time >= 2020-07-01 00:00:00 and g.order_time <= 2020-07-31 23:59:59; 找出2020年7月份销量最高的商品 select g.goods_id, Max(m.cnt) from (select g.goods_id, count(g.goods_num) AS cnt from order_goods g left jion order_info i on g.order_id = i.order_id where g.order_time >= 2020-07-01 00:00:00 and g.order_time <= 2020-07-31 23:59:59 group by g.goods_id) m
#秋招##面经##瑛太莱#