题解 | #计算商城中2021年每月的GMV#
计算商城中2021年每月的GMV
https://www.nowcoder.com/practice/5005cbf5308249eda1fbf666311753bf
-- GMV:已经付款订单金额和未付款订单金额之和(不包含已退款订单) select date_format (event_time, '%Y-%m') as month, sum(total_amount) as GMV from tb_order_overall where status <> 2 -- 该场景下:year(event_time),left(event_time, 4),substring(event_time, 1, 4)效果等价 -- and year(event_time)= '2021' -- and left(event_time, 4)= '2021' and substring(event_time, 1, 4) = '2021' group by month having sum(total_amount) > 100000 order by GMV
SQL大厂面试题 文章被收录于专栏
牛客网sql大厂面试题题解~