日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

LeetCode MySQL 1511. Customer Order Frequency

發(fā)布時(shí)間:2024/7/5 数据库 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 LeetCode MySQL 1511. Customer Order Frequency 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

文章目錄

    • 1. 題目
    • 2. 解題

1. 題目

Table: Customers

+---------------+---------+ | Column Name | Type | +---------------+---------+ | customer_id | int | | name | varchar | | country | varchar | +---------------+---------+ customer_id is the primary key for this table. This table contains information of the customers in the company.

Table: Product

+---------------+---------+ | Column Name | Type | +---------------+---------+ | product_id | int | | description | varchar | | price | int | +---------------+---------+ product_id is the primary key for this table. This table contains information of the products in the company. price is the product cost.

Table: Orders

+---------------+---------+ | Column Name | Type | +---------------+---------+ | order_id | int | | customer_id | int | | product_id | int | | order_date | date | | quantity | int | +---------------+---------+ order_id is the primary key for this table. This table contains information on customer orders. customer_id is the id of the customer who bought "quantity" products with id "product_id". Order_date is the date in format ('YYYY-MM-DD') when the order was shipped.

Write an SQL query to report the customer_id and customer_name of customers who have spent at least $100 in each month of June and July 2020.

Return the result table in any order.

The query result format is in the following example.

Customers +--------------+-----------+-------------+ | customer_id | name | country | +--------------+-----------+-------------+ | 1 | Winston | USA | | 2 | Jonathan | Peru | | 3 | Moustafa | Egypt | +--------------+-----------+-------------+Product +--------------+-------------+-------------+ | product_id | description | price | +--------------+-------------+-------------+ | 10 | LC Phone | 300 | | 20 | LC T-Shirt | 10 | | 30 | LC Book | 45 | | 40 | LC Keychain | 2 | +--------------+-------------+-------------+Orders +--------------+-------------+-------------+-------------+-----------+ | order_id | customer_id | product_id | order_date | quantity | +--------------+-------------+-------------+-------------+-----------+ | 1 | 1 | 10 | 2020-06-10 | 1 | | 2 | 1 | 20 | 2020-07-01 | 1 | | 3 | 1 | 30 | 2020-07-08 | 2 | | 4 | 2 | 10 | 2020-06-15 | 2 | | 5 | 2 | 40 | 2020-07-01 | 10 | | 6 | 3 | 20 | 2020-06-24 | 2 | | 7 | 3 | 30 | 2020-06-25 | 2 | | 9 | 3 | 30 | 2020-05-08 | 3 | +--------------+-------------+-------------+-------------+-----------+Result table: +--------------+------------+ | customer_id | name | +--------------+------------+ | 1 | Winston | +--------------+------------+ Winston spent $300 (300 * 1) in June and $100 ( 10 * 1 + 45 * 2) in July 2020. Jonathan spent $600 (300 * 2) in June and $20 ( 2 * 10) in July 2020. Moustafa spent $110 (10 * 2 + 45 * 2) in June and $0 in July 2020.

來源:力扣(LeetCode)
鏈接:https://leetcode-cn.com/problems/customer-order-frequency
著作權(quán)歸領(lǐng)扣網(wǎng)絡(luò)所有。商業(yè)轉(zhuǎn)載請(qǐng)聯(lián)系官方授權(quán),非商業(yè)轉(zhuǎn)載請(qǐng)注明出處。

2. 解題

  • 返回6月和7月都花了至少100美元的人
# Write your MySQL query statement below select o.customer_id, c.name from Customers c, Product p, Orders o where c.customer_id = o.customer_id and p.product_id = o.product_id group by o.customer_id having (sum(case when o.order_date like '2020-06%' then o.quantity*p.price else 0 end) >= 100andsum(case when o.order_date like '2020-07%' then o.quantity*p.price else 0 end) >= 100 )

762 ms


我的CSDN博客地址 https://michael.blog.csdn.net/

長按或掃碼關(guān)注我的公眾號(hào)(Michael阿明),一起加油、一起學(xué)習(xí)進(jìn)步!

總結(jié)

以上是生活随笔為你收集整理的LeetCode MySQL 1511. Customer Order Frequency的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 美女干b视频 | 国产资源在线播放 | 香蕉久久网 | 精品无码国产av一区二区三区 | 黄色一级视频免费观看 | 中文av在线播放 | 国产理论av| 午夜影院一区二区三区 | 超碰爱爱| 日本污网站 | 国产超碰人人 | 中文无码日韩欧 | 一区在线免费观看 | 欧美大片免费看 | 在线播放你懂得 | 欧美激情黑人 | 97人妻精品一区二区三区免费 | 秋霞视频在线 | 日本女优在线看 | 免费污视频 | 成人福利影院 | 婷婷网址 | 亚洲精品久久久狠狠狠爱 | 精品一区在线 | 污视频软件在线观看 | 国产精品51麻豆cm传媒 | 懂色av中文一区二区三区天美 | 国产一区二区精品在线观看 | 久久中文字幕人妻熟av女蜜柚m | 亚洲欧美高清在线 | 嫩草影院在线观看视频 | 69av片| 久久久久久久久久久久久女国产乱 | 国产午夜福利视频在线观看 | 黄色片网站视频 | 禁止18在线观看 | 亚洲成人一区二区 | 东北毛片| 久久精品国产亚洲av久一一区 | 日日干日日插 | 国产欧美一区二区三区在线看蜜臂 | 国产欧美日韩精品区一区二污污污 | 爱爱视频免费看 | a毛片在线 | 美女国产网站 | 国产乱人乱精一区二视频国产精品 | 日本中文字幕视频在线 | 日韩欧美成人一区 | 琪琪色网| 久色资源 | 变态另类一区 | 国产精品边吃奶边做爽 | 国产视频在线看 | 嫩草影院国产 | 天海翼一二三区 | 久av在线 | 国产情侣在线视频 | 黄色免费在线观看视频 | 中日韩黄色片 | 日韩特黄一级片 | 国产精品激情偷乱一区二区∴ | 国产精品资源网 | 17草在线| 女futa攻玩遍整个后宫 | 国产精品久久久免费观看 | 欧美成年人视频 | 久久av高潮av无码av喷吹 | 性xx紧缚网站 | 国产精品一二三区 | 国产50页 | 国产一级片免费视频 | 亚洲欧美一区二区在线观看 | 99999视频 | 国产日产欧洲无码视频 | 99视频免费观看 | 岛国一区| 最新在线黄色网址 | 国产福利在线观看视频 | 国产1区2区3区4区 | 麻豆成人免费 | 99精品视频免费版的特色功能 | 伊人久久久久噜噜噜亚洲熟女综合 | 特淫毛片| 欧美成人黄色小视频 | 成人黄色在线 | 在线观看免费福利 | 亚洲欧美另类激情 | 男人操女人下面 | 邻居少妇张开双腿让我爽一夜 | 精品人妻一区二区三区四区在线 | www.777含羞草| 男生插女生视频在线观看 | 97久久超碰| 丰满岳乱妇一区二区三区 | 五月婷婷一区二区 | www.日本高清 | 欧美亚洲中文精品字幕 | 久久精品一区二区 | 国产熟女一区二区三区五月婷 |