1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-06 07:51:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

批量更新数据

This commit is contained in:
2025-01-09 20:29:41 +08:00
parent 04ecea043d
commit 48cdd06c2b
5053 changed files with 156164 additions and 135322 deletions

View File

@@ -7,17 +7,17 @@
"boundTopicId": 1331,
"title": "Trips and Users",
"titleSlug": "trips-and-users",
"content": "<p>Table: <code>Trips</code></p>\n\n<pre>\n+-------------+----------+\n| Column Name | Type |\n+-------------+----------+\n| id | int |\n| client_id | int |\n| driver_id | int |\n| city_id | int |\n| status | enum |\n| request_at | date | \n+-------------+----------+\nid is the primary key (column with unique values) for this table.\nThe table holds all taxi trips. Each trip has a unique id, while client_id and driver_id are foreign keys to the users_id at the Users table.\nStatus is an ENUM (category) type of (&#39;completed&#39;, &#39;cancelled_by_driver&#39;, &#39;cancelled_by_client&#39;).\n</pre>\n\n<p>&nbsp;</p>\n\n<p>Table: <code>Users</code></p>\n\n<pre>\n+-------------+----------+\n| Column Name | Type |\n+-------------+----------+\n| users_id | int |\n| banned | enum |\n| role | enum |\n+-------------+----------+\nusers_id is the primary key (column with unique values) for this table.\nThe table holds all users. Each user has a unique users_id, and role is an ENUM type of (&#39;client&#39;, &#39;driver&#39;, &#39;partner&#39;).\nbanned is an ENUM (category) type of (&#39;Yes&#39;, &#39;No&#39;).\n</pre>\n\n<p>&nbsp;</p>\n\n<p>The <strong>cancellation rate</strong> is computed by dividing the number of canceled (by client or driver) requests with unbanned users by the total number of requests with unbanned users on that day.</p>\n\n<p>Write a solution to find the <strong>cancellation rate</strong> of requests with unbanned users (<strong>both client and driver must not be banned</strong>) each day between <code>&quot;2013-10-01&quot;</code> and <code>&quot;2013-10-03&quot;</code>. Round <code>Cancellation Rate</code> to <strong>two decimal</strong> points.</p>\n\n<p>Return the result table in <strong>any order</strong>.</p>\n\n<p>The&nbsp;result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nTrips table:\n+----+-----------+-----------+---------+---------------------+------------+\n| id | client_id | driver_id | city_id | status | request_at |\n+----+-----------+-----------+---------+---------------------+------------+\n| 1 | 1 | 10 | 1 | completed | 2013-10-01 |\n| 2 | 2 | 11 | 1 | cancelled_by_driver | 2013-10-01 |\n| 3 | 3 | 12 | 6 | completed | 2013-10-01 |\n| 4 | 4 | 13 | 6 | cancelled_by_client | 2013-10-01 |\n| 5 | 1 | 10 | 1 | completed | 2013-10-02 |\n| 6 | 2 | 11 | 6 | completed | 2013-10-02 |\n| 7 | 3 | 12 | 6 | completed | 2013-10-02 |\n| 8 | 2 | 12 | 12 | completed | 2013-10-03 |\n| 9 | 3 | 10 | 12 | completed | 2013-10-03 |\n| 10 | 4 | 13 | 12 | cancelled_by_driver | 2013-10-03 |\n+----+-----------+-----------+---------+---------------------+------------+\nUsers table:\n+----------+--------+--------+\n| users_id | banned | role |\n+----------+--------+--------+\n| 1 | No | client |\n| 2 | Yes | client |\n| 3 | No | client |\n| 4 | No | client |\n| 10 | No | driver |\n| 11 | No | driver |\n| 12 | No | driver |\n| 13 | No | driver |\n+----------+--------+--------+\n<strong>Output:</strong> \n+------------+-------------------+\n| Day | Cancellation Rate |\n+------------+-------------------+\n| 2013-10-01 | 0.33 |\n| 2013-10-02 | 0.00 |\n| 2013-10-03 | 0.50 |\n+------------+-------------------+\n<strong>Explanation:</strong> \nOn 2013-10-01:\n - There were 4 requests in total, 2 of which were canceled.\n - However, the request with Id=2 was made by a banned client (User_Id=2), so it is ignored in the calculation.\n - Hence there are 3 unbanned requests in total, 1 of which was canceled.\n - The Cancellation Rate is (1 / 3) = 0.33\nOn 2013-10-02:\n - There were 3 requests in total, 0 of which were canceled.\n - The request with Id=6 was made by a banned client, so it is ignored.\n - Hence there are 2 unbanned requests in total, 0 of which were canceled.\n - The Cancellation Rate is (0 / 2) = 0.00\nOn 2013-10-03:\n - There were 3 requests in total, 1 of which was canceled.\n - The request with Id=8 was made by a banned client, so it is ignored.\n - Hence there are 2 unbanned request in total, 1 of which were canceled.\n - The Cancellation Rate is (1 / 2) = 0.50\n</pre>\n",
"content": "<p>Table: <code>Trips</code></p>\n\n<pre>\n+-------------+----------+\n| Column Name | Type |\n+-------------+----------+\n| id | int |\n| client_id | int |\n| driver_id | int |\n| city_id | int |\n| status | enum |\n| request_at | varchar | \n+-------------+----------+\nid is the primary key (column with unique values) for this table.\nThe table holds all taxi trips. Each trip has a unique id, while client_id and driver_id are foreign keys to the users_id at the Users table.\nStatus is an ENUM (category) type of (&#39;completed&#39;, &#39;cancelled_by_driver&#39;, &#39;cancelled_by_client&#39;).\n</pre>\n\n<p>&nbsp;</p>\n\n<p>Table: <code>Users</code></p>\n\n<pre>\n+-------------+----------+\n| Column Name | Type |\n+-------------+----------+\n| users_id | int |\n| banned | enum |\n| role | enum |\n+-------------+----------+\nusers_id is the primary key (column with unique values) for this table.\nThe table holds all users. Each user has a unique users_id, and role is an ENUM type of (&#39;client&#39;, &#39;driver&#39;, &#39;partner&#39;).\nbanned is an ENUM (category) type of (&#39;Yes&#39;, &#39;No&#39;).\n</pre>\n\n<p>&nbsp;</p>\n\n<p>The <strong>cancellation rate</strong> is computed by dividing the number of canceled (by client or driver) requests with unbanned users by the total number of requests with unbanned users on that day.</p>\n\n<p>Write a solution to find the <strong>cancellation rate</strong> of requests with unbanned users (<strong>both client and driver must not be banned</strong>) each day between <code>&quot;2013-10-01&quot;</code> and <code>&quot;2013-10-03&quot;</code>. Round <code>Cancellation Rate</code> to <strong>two decimal</strong> points.</p>\n\n<p>Return the result table in <strong>any order</strong>.</p>\n\n<p>The&nbsp;result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nTrips table:\n+----+-----------+-----------+---------+---------------------+------------+\n| id | client_id | driver_id | city_id | status | request_at |\n+----+-----------+-----------+---------+---------------------+------------+\n| 1 | 1 | 10 | 1 | completed | 2013-10-01 |\n| 2 | 2 | 11 | 1 | cancelled_by_driver | 2013-10-01 |\n| 3 | 3 | 12 | 6 | completed | 2013-10-01 |\n| 4 | 4 | 13 | 6 | cancelled_by_client | 2013-10-01 |\n| 5 | 1 | 10 | 1 | completed | 2013-10-02 |\n| 6 | 2 | 11 | 6 | completed | 2013-10-02 |\n| 7 | 3 | 12 | 6 | completed | 2013-10-02 |\n| 8 | 2 | 12 | 12 | completed | 2013-10-03 |\n| 9 | 3 | 10 | 12 | completed | 2013-10-03 |\n| 10 | 4 | 13 | 12 | cancelled_by_driver | 2013-10-03 |\n+----+-----------+-----------+---------+---------------------+------------+\nUsers table:\n+----------+--------+--------+\n| users_id | banned | role |\n+----------+--------+--------+\n| 1 | No | client |\n| 2 | Yes | client |\n| 3 | No | client |\n| 4 | No | client |\n| 10 | No | driver |\n| 11 | No | driver |\n| 12 | No | driver |\n| 13 | No | driver |\n+----------+--------+--------+\n<strong>Output:</strong> \n+------------+-------------------+\n| Day | Cancellation Rate |\n+------------+-------------------+\n| 2013-10-01 | 0.33 |\n| 2013-10-02 | 0.00 |\n| 2013-10-03 | 0.50 |\n+------------+-------------------+\n<strong>Explanation:</strong> \nOn 2013-10-01:\n - There were 4 requests in total, 2 of which were canceled.\n - However, the request with Id=2 was made by a banned client (User_Id=2), so it is ignored in the calculation.\n - Hence there are 3 unbanned requests in total, 1 of which was canceled.\n - The Cancellation Rate is (1 / 3) = 0.33\nOn 2013-10-02:\n - There were 3 requests in total, 0 of which were canceled.\n - The request with Id=6 was made by a banned client, so it is ignored.\n - Hence there are 2 unbanned requests in total, 0 of which were canceled.\n - The Cancellation Rate is (0 / 2) = 0.00\nOn 2013-10-03:\n - There were 3 requests in total, 1 of which was canceled.\n - The request with Id=8 was made by a banned client, so it is ignored.\n - Hence there are 2 unbanned request in total, 1 of which were canceled.\n - The Cancellation Rate is (1 / 2) = 0.50\n</pre>\n",
"translatedTitle": "行程和用户",
"translatedContent": "表:<code>Trips</code>\n<div class=\"original__bRMd\">\n<div>\n<pre>\n+-------------+----------+\n| Column Name | Type |\n+-------------+----------+\n| id | int |\n| client_id | int |\n| driver_id | int |\n| city_id | int |\n| status | enum |\n| request_at | date | \n+-------------+----------+\nid 是这张表的主键(具有唯一值的列)。\n这张表中存所有出租车的行程信息。每段行程有唯一 id ,其中 client_id 和 driver_id 是 Users 表中 users_id 的外键。\nstatus 是一个表示行程状态的枚举类型,枚举成员为(completed, cancelled_by_driver, cancelled_by_client) 。\n</pre>\n\n<p>&nbsp;</p>\n\n<div class=\"original__bRMd\">\n<div>\n<p>表:<code>Users</code></p>\n</div>\n</div>\n\n<pre>\n+-------------+----------+\n| Column Name | Type |\n+-------------+----------+\n| users_id | int |\n| banned | enum |\n| role | enum |\n+-------------+----------+\nusers_id 是这张表的主键(具有唯一值的列)。\n这张表中存所有用户每个用户都有一个唯一的 users_id role 是一个表示用户身份的枚举类型,枚举成员为 (client, driver, partner) 。\nbanned 是一个表示用户是否被禁止的枚举类型,枚举成员为 (Yes, No) 。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>取消率</strong> 的计算方式如下:(被司机或乘客取消的非禁止用户生成的订单数量) / (非禁止用户生成的订单总数)。</p>\n\n<p>编写解决方案找出&nbsp;<code>\"2013-10-01\"</code><strong>&nbsp;</strong>至&nbsp;<code>\"2013-10-03\"</code><strong>&nbsp;</strong>期间非禁止用户(<strong>乘客和司机都必须未被禁止</strong>)的取消率。非禁止用户即 banned 为 No 的用户,禁止用户即 banned 为 Yes 的用户。其中取消率 <code>Cancellation Rate</code> 需要四舍五入保留 <strong>两位小数</strong> 。</p>\n\n<p>返回结果表中的数据 <strong>无顺序要求</strong> 。</p>\n\n<p>结果格式如下例所示。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong> \nTrips 表:\n+----+-----------+-----------+---------+---------------------+------------+\n| id | client_id | driver_id | city_id | status | request_at |\n+----+-----------+-----------+---------+---------------------+------------+\n| 1 | 1 | 10 | 1 | completed | 2013-10-01 |\n| 2 | 2 | 11 | 1 | cancelled_by_driver | 2013-10-01 |\n| 3 | 3 | 12 | 6 | completed | 2013-10-01 |\n| 4 | 4 | 13 | 6 | cancelled_by_client | 2013-10-01 |\n| 5 | 1 | 10 | 1 | completed | 2013-10-02 |\n| 6 | 2 | 11 | 6 | completed | 2013-10-02 |\n| 7 | 3 | 12 | 6 | completed | 2013-10-02 |\n| 8 | 2 | 12 | 12 | completed | 2013-10-03 |\n| 9 | 3 | 10 | 12 | completed | 2013-10-03 |\n| 10 | 4 | 13 | 12 | cancelled_by_driver | 2013-10-03 |\n+----+-----------+-----------+---------+---------------------+------------+\nUsers 表:\n+----------+--------+--------+\n| users_id | banned | role |\n+----------+--------+--------+\n| 1 | No | client |\n| 2 | Yes | client |\n| 3 | No | client |\n| 4 | No | client |\n| 10 | No | driver |\n| 11 | No | driver |\n| 12 | No | driver |\n| 13 | No | driver |\n+----------+--------+--------+\n<strong>输出:</strong>\n+------------+-------------------+\n| Day | Cancellation Rate |\n+------------+-------------------+\n| 2013-10-01 | 0.33 |\n| 2013-10-02 | 0.00 |\n| 2013-10-03 | 0.50 |\n+------------+-------------------+\n<strong>解释:</strong>\n2013-10-01\n - 共有 4 条请求,其中 2 条取消。\n - 然而id=2 的请求是由禁止用户user_id=2发出的所以计算时应当忽略它。\n - 因此,总共有 3 条非禁止请求参与计算,其中 1 条取消。\n - 取消率为 (1 / 3) = 0.33\n2013-10-02\n - 共有 3 条请求,其中 0 条取消。\n - 然而id=6 的请求是由禁止用户发出的,所以计算时应当忽略它。\n - 因此,总共有 2 条非禁止请求参与计算,其中 0 条取消。\n - 取消率为 (0 / 2) = 0.00\n2013-10-03\n - 共有 3 条请求,其中 1 条取消。\n - 然而id=8 的请求是由禁止用户发出的,所以计算时应当忽略它。\n - 因此,总共有 2 条非禁止请求参与计算,其中 1 条取消。\n - 取消率为 (1 / 2) = 0.50\n</pre>\n</div>\n</div>\n",
"translatedContent": "表:<code>Trips</code>\n<div class=\"original__bRMd\">\n<div>\n<pre>\n+-------------+----------+\n| Column Name | Type |\n+-------------+----------+\n| id | int |\n| client_id | int |\n| driver_id | int |\n| city_id | int |\n| status | enum |\n| request_at | varchar | \n+-------------+----------+\nid 是这张表的主键(具有唯一值的列)。\n这张表中存所有出租车的行程信息。每段行程有唯一 id ,其中 client_id 和 driver_id 是 Users 表中 users_id 的外键。\nstatus 是一个表示行程状态的枚举类型,枚举成员为(completed, cancelled_by_driver, cancelled_by_client) 。\n</pre>\n\n<p>&nbsp;</p>\n\n<div class=\"original__bRMd\">\n<div>\n<p>表:<code>Users</code></p>\n</div>\n</div>\n\n<pre>\n+-------------+----------+\n| Column Name | Type |\n+-------------+----------+\n| users_id | int |\n| banned | enum |\n| role | enum |\n+-------------+----------+\nusers_id 是这张表的主键(具有唯一值的列)。\n这张表中存所有用户每个用户都有一个唯一的 users_id role 是一个表示用户身份的枚举类型,枚举成员为 (client, driver, partner) 。\nbanned 是一个表示用户是否被禁止的枚举类型,枚举成员为 (Yes, No) 。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>取消率</strong> 的计算方式如下:(被司机或乘客取消的非禁止用户生成的订单数量) / (非禁止用户生成的订单总数)。</p>\n\n<p>编写解决方案找出&nbsp;<code>\"2013-10-01\"</code><strong>&nbsp;</strong>至&nbsp;<code>\"2013-10-03\"</code><strong>&nbsp;</strong>期间非禁止用户(<strong>乘客和司机都必须未被禁止</strong>)的取消率。非禁止用户即 banned 为 No 的用户,禁止用户即 banned 为 Yes 的用户。其中取消率 <code>Cancellation Rate</code> 需要四舍五入保留 <strong>两位小数</strong> 。</p>\n\n<p>返回结果表中的数据 <strong>无顺序要求</strong> 。</p>\n\n<p>结果格式如下例所示。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong> \nTrips 表:\n+----+-----------+-----------+---------+---------------------+------------+\n| id | client_id | driver_id | city_id | status | request_at |\n+----+-----------+-----------+---------+---------------------+------------+\n| 1 | 1 | 10 | 1 | completed | 2013-10-01 |\n| 2 | 2 | 11 | 1 | cancelled_by_driver | 2013-10-01 |\n| 3 | 3 | 12 | 6 | completed | 2013-10-01 |\n| 4 | 4 | 13 | 6 | cancelled_by_client | 2013-10-01 |\n| 5 | 1 | 10 | 1 | completed | 2013-10-02 |\n| 6 | 2 | 11 | 6 | completed | 2013-10-02 |\n| 7 | 3 | 12 | 6 | completed | 2013-10-02 |\n| 8 | 2 | 12 | 12 | completed | 2013-10-03 |\n| 9 | 3 | 10 | 12 | completed | 2013-10-03 |\n| 10 | 4 | 13 | 12 | cancelled_by_driver | 2013-10-03 |\n+----+-----------+-----------+---------+---------------------+------------+\nUsers 表:\n+----------+--------+--------+\n| users_id | banned | role |\n+----------+--------+--------+\n| 1 | No | client |\n| 2 | Yes | client |\n| 3 | No | client |\n| 4 | No | client |\n| 10 | No | driver |\n| 11 | No | driver |\n| 12 | No | driver |\n| 13 | No | driver |\n+----------+--------+--------+\n<strong>输出:</strong>\n+------------+-------------------+\n| Day | Cancellation Rate |\n+------------+-------------------+\n| 2013-10-01 | 0.33 |\n| 2013-10-02 | 0.00 |\n| 2013-10-03 | 0.50 |\n+------------+-------------------+\n<strong>解释:</strong>\n2013-10-01\n - 共有 4 条请求,其中 2 条取消。\n - 然而id=2 的请求是由禁止用户user_id=2发出的所以计算时应当忽略它。\n - 因此,总共有 3 条非禁止请求参与计算,其中 1 条取消。\n - 取消率为 (1 / 3) = 0.33\n2013-10-02\n - 共有 3 条请求,其中 0 条取消。\n - 然而id=6 的请求是由禁止用户发出的,所以计算时应当忽略它。\n - 因此,总共有 2 条非禁止请求参与计算,其中 0 条取消。\n - 取消率为 (0 / 2) = 0.00\n2013-10-03\n - 共有 3 条请求,其中 1 条取消。\n - 然而id=8 的请求是由禁止用户发出的,所以计算时应当忽略它。\n - 因此,总共有 2 条非禁止请求参与计算,其中 1 条取消。\n - 取消率为 (1 / 2) = 0.50\n</pre>\n</div>\n</div>\n",
"isPaidOnly": false,
"difficulty": "Hard",
"likes": 422,
"likes": 448,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"similarQuestions": "[{\"title\": \"Hopper Company Queries I\", \"titleSlug\": \"hopper-company-queries-i\", \"difficulty\": \"Hard\", \"translatedTitle\": \"Hopper \\u516c\\u53f8\\u67e5\\u8be2 I\", \"isPaidOnly\": true}, {\"title\": \"Hopper Company Queries II\", \"titleSlug\": \"hopper-company-queries-ii\", \"difficulty\": \"Hard\", \"translatedTitle\": \"Hopper \\u516c\\u53f8\\u67e5\\u8be2 II\", \"isPaidOnly\": true}, {\"title\": \"Hopper Company Queries III\", \"titleSlug\": \"hopper-company-queries-iii\", \"difficulty\": \"Hard\", \"translatedTitle\": \"Hopper \\u516c\\u53f8\\u67e5\\u8be2 III\", \"isPaidOnly\": true}]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false, \"cangjie\": false}",
"topicTags": [
{
"name": "Database",
@@ -59,7 +59,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"73K\", \"totalSubmission\": \"178.2K\", \"totalAcceptedRaw\": 73014, \"totalSubmissionRaw\": 178243, \"acRate\": \"41.0%\"}",
"stats": "{\"totalAccepted\": \"85.3K\", \"totalSubmission\": \"207.3K\", \"totalAcceptedRaw\": 85280, \"totalSubmissionRaw\": 207315, \"acRate\": \"41.1%\"}",
"hints": [],
"solution": null,
"status": null,
@@ -92,7 +92,7 @@
"insert into Users (users_id, banned, role) values ('13', 'No', 'driver')"
],
"enableRunCode": true,
"envInfo": "{\"mysql\":[\"MySQL\",\"<p>\\u7248\\u672c\\uff1a<code>MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"<p>mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\"<p>Oracle Sql 11.2.<\\/p>\"],\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"],\"postgresql\":[\"PostgreSQL\",\"<p>PostgreSQL 16<\\/p>\"]}",
"envInfo": "{\"mysql\":[\"MySQL\",\"<p>\\u7248\\u672c\\uff1a<code>MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"<p>mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\"<p>Oracle Sql 11.2.<\\/p>\"],\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.2.2 and NumPy 1.26.4<\\/p>\"],\"postgresql\":[\"PostgreSQL\",\"<p>PostgreSQL 16<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,