文章目录
-
- 原题题目
- 代码实现(首刷自解)
原题题目
代码实现(首刷自解)
# Write your MySQL query tatement below
SELECT customer_id,name
FROM (SELECT customer_id,DATE_FORMAT(order_date,"%Y-%m") AS dateFROM orders LEFT JOIN product USING(product_id)WHERE DATE_FORMAT(order_date,"%Y-%m") IN ("2020-06","2020-07")GROUP BY customer_id,DATE_FORMAT(order_date,"%Y-%m")HAVING SUM(price*quantity) >= 100) t1
LEFT JOINcustomers AS c
USING(customer_id)
GROUP BY customer_id
HAVING COUNT(*) = 2