## **1. 要求如下图** sql语句学习 https://www.nowcoder.com/ta/sql?from=baidusql&bd_vid=10130540574637136165 ![](https://img.kancloud.cn/6a/3e/6a3ec77e89e483b223ec1016e5659703_582x354.png) 方案1 ``` select created_at, sum(case status when 1 then amount end) as 'total_1', sum(case status when 2 then amount end) as 'total_2' from orders group by created_at ``` ![](https://img.kancloud.cn/4d/90/4d9050e6d48310e8915ab0a24e1e5917_302x80.png) 方案2 ``` select sum(amount), created_at, status from orders group by created_at,status; ``` ![](https://img.kancloud.cn/15/3a/153a6ba8531e4a61d9a8511d0708e296_365x150.png) ## **2 mysql表关联查询** ``` SELECT lm_product_apply.*, lm_custom_made.* FROM lm_product_apply LEFT JOIN lm_custom_made ON lm_product_apply.user_id = lm_custom_made.user_id WHERE lm_product_apply.date = "2022-10-12" ```