当前位置: 代码迷 >> 综合 >> Leetcode Mysql 1511. 消费者下单频率(DAY 17)
  详细解决方案

Leetcode Mysql 1511. 消费者下单频率(DAY 17)

热度:91   发布时间:2023-11-17 16:51:04.0

文章目录

    • 原题题目
    • 代码实现(首刷自解)


原题题目


在这里插入图片描述


代码实现(首刷自解)


# 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
  相关解决方案