LeetCode 2701 Consecutive Transactions with Increasing Amounts_每日资讯

<p>Table: <code>Transactions</code></p>

<pre>


(相关资料图)

+------------------+------+

| Column Name      | Type |

+------------------+------+

| transaction_id   | int  |

| customer_id      | int  |

| transaction_date | date |

| amount           | int  |

+------------------+------+

transaction_id is the primary key of this table.

Each row contains information about transactions that includes unique (customer_id, transaction_date) along with the corresponding customer_id and amount.  

</pre>

<p>Write an SQL query to find the customers who have made consecutive transactions with increasing <code>amount</code>;for at least three consecutive days. Include the <code>customer_id</code>,;start date of the consecutive transactions;period and the end date of the consecutive transactions period. There can be multiple consecutive transactions by a customer.</p>

<p>Return <em>the result table ordered by</em> <code>customer_id</code> <em>in <strong>ascending</strong> order.</em></p>

<p>The query result format is in the following example.</p>

<p>;</p>

<p><strong class="example">Example 1:</strong></p>

<strong>Input:</strong>;

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|

| 10 | 105 | 2023-05-04 | 300|

| 11 | 105 | 2023-05-12 | 250|

| 12 | 105 | 2023-05-13 | 260|

| 13 | 105 | 2023-05-14 | 270|

<strong>Output:</strong>;

| customer_id | consecutive_start | consecutive_end |

-|-|-|

| 101 | 2023-05-01 |2023-05-03|

| 105 | 2023-05-01 |2023-05-04|

| 105 | 2023-05-12 |2023-05-14|

<strong>Explanation:</strong>

- customer_id 101 has made consecutive transactions with increasing amounts from May 1st, 2023, to May 3rd, 2023

- customer_id 102 does not have any consecutive transactions for at least 3 days.;

- customer_id 105 has two sets of consecutive transactions: from May 1st, 2023, to May 4th, 2023, and from May 12th, 2023, to May 14th, 2023.;

customer_id is sorted in ascending order.

标签:

最近更新

LeetCode 2701 Consecutive Transactions with Increasing Amounts_每日资讯
2023-07-04 07:48:57
【警方视点】多措并举精准发力 哈市强化摩托车交通安全管理 世界通讯
2023-07-04 07:15:21
实时焦点:夏粮旺季收购进入集中上量阶段
2023-07-04 06:36:27
银联商务统一认证平台(银联商务登录系统)
2023-07-04 05:57:41
天天观察:职业生涯规划书_职业生涯发展规划
2023-07-04 04:14:01
五毒是哪几个动物_五毒是哪几个
2023-07-04 01:57:29
香港建国际航运中心 招商局续办世界航商大会
2023-07-03 23:11:54
藤原浩联名款Beats Fit Pro亮相 将于7月7日全球发售 全球报资讯
2023-07-03 22:21:04
环球热头条丨最亲最爱的人(关于最亲最爱的人介绍)
2023-07-03 21:51:29
第二届国际先进功能材料研讨会在杭州启幕
2023-07-03 21:09:55
当前快看:《闪电侠》票房2.45亿美元 网友:活该 让你找罪犯演主角
2023-07-03 20:10:14
一刀一个牛头人是啥梗_牛头人是啥梗-世界短讯
2023-07-03 19:55:09
环球快讯:山西太原机场恢复至泰国普吉航线航班
2023-07-03 19:13:11
宇通重工:联合体中标12.25亿元郑州经济技术开发区环卫、绿化一体化服务项目
2023-07-03 18:30:11
天福(06868.HK)7月3日收盘跌0.22% 速读
2023-07-03 17:55:52
专场招聘会、直播带岗……他们这样“护航”高校毕业生就业
2023-07-03 17:27:49
《尘缘》纪若尘喜欢张殷殷还是顾清 张殷殷纪若尘最后在一起了吗?
2023-07-03 16:54:52
西藏自治区山南市副市长王霞接受纪律审查和监察调查 天天快看点
2023-07-03 16:56:54
【全球新要闻】泛鼎国际全方位支持中国品牌出海
2023-07-03 16:27:52
根据大脑连接预测沉思 全球速讯
2023-07-03 15:45:55
07年永源UFO 1.6怎么样?外观、性能、用户评价全面解析!
2023-07-03 15:33:01
今日热门!瑕不掩瑜瑜不掩瑕瑕非瑜瑜非瑕瑕即是瑜瑜即是瑕非瑕非瑜非瑜非瑕_瑕不掩瑜
2023-07-03 15:06:24
每日快报!今日澳元/美元汇率最新交易策略(2023年7月3日)
2023-07-03 14:50:17
机器人概念股午后持续下探,绿的谐波跌超9%
2023-07-03 14:13:44
天天通讯!柬埔寨夜店起火致8死 包括6名中国人
2023-07-03 13:17:50
怎么知道对方手机位置(想知道对方手机位置)-当前信息
2023-07-03 12:37:31
本地收藏夹怎么找回_本地收藏夹
2023-07-03 12:17:02
德阳旌阳区交通运输行业党委举办“红色法务”专题讲座
2023-07-03 11:42:55
多年恋爱脑,一部电影全给我治好了
2023-07-02 19:14:35
环球要闻:《泰拉瑞亚》难出新作 制作人:游戏太火了 分不开身
2023-07-02 18:10:36