Table: Transactions
(资料图片)
+------------------+------+
| Column Name | Type |
+------------------+------+
| transaction_id | int |
| customer_id | int |
| transaction_date | date |
| amount | int |
+------------------+------+
transaction_id is the primary key of this row contains information about transactions that includes unique (customer_id, transaction_date) along with the corresponding customer_id and amount.
Write an SQL query to find all customer_id
who made the maximum number of transactions on consecutive days.
Return all customer_id
with the maximum number of consecutive transactions. Order the result table by customer_id
in ascending order.
The query result format is in the following example.
Example 1:
Input:
Transactions table:
+----------------+-------------+------------------+--------+
| transaction_id | customer_id | transaction_date | amount |
+----------------+-------------+------------------+--------+
| 1 | 101 | 2023-05-01 | 100 |
| 2 | 101 | 2023-05-02 | 150 |
| 3 | 101 | 2023-05-03 | 200 |
| 4 | 102 | 2023-05-01 | 50 |
| 5 | 102 | 2023-05-03 | 100 |
| 6 | 102 | 2023-05-04 | 200 |
| 7 | 105 | 2023-05-01 | 100 |
| 8 | 105 | 2023-05-02 | 150 |
| 9 | 105 | 2023-05-03 | 200 |
+----------------+-------------+------------------+--------+
Output:
+-------------+
| customer_id |
+-------------+
| 101 |
| 105 |
+-------------+
Explanation:
- customer_id 101 has a total of 3 transactions, and all of them are consecutive.- customer_id 102 has a total of 3 transactions, but only 2 of them are consecutive. - customer_id 105 has a total of 3 transactions, and all of them are total, the highest number of consecutive transactions is 3, achieved by customer_id 101 and 105. The customer_id are sorted in ascending order.
DescriptionTable:Transactions+------------------+------+|ColumnNam
电影《封神第一部》于8月11日宣布,其密钥延期至2023年9月19日,原定于
城市地下空间防汛,“万一”似乎无法完全避免。·“新建小区的地下...
直播吧8月12日讯据记者MarceloBechler消息,巴萨希望先给内马尔提供一
8月11日北向资金增持5 64万股华海清科。近5个交易日中,获北向资金增持
截至2023年8月11日收盘,中际旭创(300308)报收于121 98元,下跌1 64%,
截至2023年8月11日收盘,骏成科技(301106)报收于39 53元,较上周的39
为更好推动“上海农业科创谷”明晰功能定位、找准研究领域、厘清发...
格隆汇8月11日丨中国水业集团(01129 HK)宣布,公司董事会会议将于2023
今天小红来为大家带来的是962121上海住宅物业网是什么网,962121上海住
今天上午10时,上海市民艺术夜校秋季班正式开启报名,峰时一下子涌入了
1、登录相关平台账户,点击提现按钮,按照操作提示绑卡后完成提现;单
诚志股份(SZ000990,收盘价:元)8月11日晚间发布公告称,截至公告日
潮新闻客户端记者陈薇通讯员李昭奕8月11日,位于浙南南雁荡山腹地,全
东方网·演兵场8月11日报道:据@西部战区消息,新疆军区某合成团不久前
有投资者在投资者互动平台提问:问下中报为什么还没有公布,计划什么时
格隆汇8月11日丨有投资者向国星光电(002449)(002449 SZ)提问,“起步就
看来老将比赛状态起伏都比较大,再加上参加这次里约热内卢挑战赛时间都
清研环境08月11日主力(dde大单净额)净流出993 74万元,涨跌幅为4 23%
虹膜识别技术是基于眼睛中的虹膜进行身份识别,应用于安防设备(如门禁
英伟达近日和以色列理工学院、巴伊兰大学和西蒙弗雷泽大学合作,发布了
“医生,我看别人治失眠都是吃艾司唑仑,你怎么给我开的阿普唑仑啊
企查查APP显示,近日,广东易特创新能源有限公司成立,法定代表人为赵
凌玮科技(301373)08月11日在投资者关系平台上答复了投资者关心的问题。
8月10日下午,小米正式宣布了旗下最新的折叠屏手机——小米MIXFold3,
鲸鱼是哺乳动物中体型最大的一类,它们生活在海洋中,并且需要呼吸空气
天眼查App显示,8月9日,康师傅方便面投资(中国)有限公司发生工商变
500多平方米的车间里,80多个村民正在高速缝纫机前缝制帽子。江苏省泗
新华社曼谷8月10日电(记者王媛媛、林昊)第二十一届亚洲象棋锦标赛10
在电气化时代,所有传统汽车品牌都面临着转型困境,超跑品牌更是深受其