五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

leetcode 2474. Customers With Strictly Increasing Purchases

2022-11-28 12:39 作者:您是打尖兒還是住店呢  | 我要投稿

Description

Table:?Orders

+-------------------+------+?

| Column Name ?| Type |

+--------------------+------+?

|order_id ? ? | int ?|?

| customer_id ?| int ?|

| order_date ? | date |?

| price ? ? ? ?| int ?|

?order_id is the primary key for this table. Each row contains the id of an order, the id of customer that ordered it, the date of the order, and its price.

?

Write an SQL query to report the IDs of the customers with the?total purchases?strictly increasing yearly.

  • The?total purchases?of a customer in one year is the sum of the prices of their orders in that year. If for some year the customer did not make any order, we consider the total purchases?0.

  • The first year to consider for each customer is the year of their?first order.

  • The last year to consider for each customer is the year of their?last order.

Return the result table?in any order.

The query result format is in the following example.

?

Example 1:

Input: Orders table:

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

| order_id | customer_id | order_date | price |

+----------+-------------+------------+-------+?

| 1 ? ? ? ?| 1 ? ? ? ? ? | 2019-07-01 | 1100 ?|?

| 2 ? ? ? ?| 1 ? ? ? ? ? | 2019-11-01 | 1200 ?|?

| 3 ? ? ? ?| 1 ? ? ? ? ? | 2020-05-26 | 3000 ?|

| 4 ? ? ? ?| 1 ? ? ? ? ? | 2021-08-31 | 3100 ?|?

| 5 ? ? ? ?| 1 ? ? ? ? ? | 2022-12-07 | 4700 ?|?

| 6 ? ? ? ?| 2 ? ? ? ? ? | 2015-01-01 | 700 ? |?

| 7 ? ? ? ?| 2 ? ? ? ? ? | 2017-11-07 | 1000 ?|?

| 8 ? ? ? ?| 3 ? ? ? ? ? | 2017-01-01 | 900 ? |?

| 9 ? ? ? ?| 3 ? ? ? ? ? | 2018-11-07 | 900 ? |?

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

Output:

+-------------+?

| customer_id |

+-------------+?

|1 ? ? ? ? ? |?

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

Explanation: Customer 1:?

The first year is 2019 and the last year is 2022 ?- 2019: 1100 + 1200 = 2300 ?- 2020: 3000 ?- 2021: 3100 ?- 2022: 4700 ?We can see that the total purchases are strictly increasing yearly, so we include customer 1 in the answer.?

Customer 2: The first year is 2015 and the last year is 2017 ?- 2015: 700 ?- 2016: 0 ?- 2017: 1000 ?We do not include customer 2 in the answer because the total purchases are not strictly increasing. Note that customer 2 did not make any purchases in 2016.?

Customer 3: The first year is 2017, and the last year is 2018 ?- 2017: 900 ?- 2018: 900 ?We can see that the total purchases are strictly increasing yearly, so we include customer 1 in the answer.


leetcode 2474. Customers With Strictly Increasing Purchases的評論 (共 條)

分享到微博請遵守國家法律
永川市| 云安县| 静乐县| 南乐县| 丰县| 珲春市| 鸡西市| 呼图壁县| 西青区| 泾源县| 宜君县| 北海市| 齐河县| 上虞市| 南和县| 个旧市| 临沭县| 红河县| 田林县| 锡林郭勒盟| 红安县| 土默特右旗| 阳朔县| 侯马市| 大英县| 呼和浩特市| 钟祥市| 普兰县| 石城县| 绥德县| 怀宁县| 华蓥市| 锡林郭勒盟| 武胜县| 读书| 芦溪县| 灵武市| 昌图县| 周口市| 黔西县| 呼图壁县|