1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-25 17:50:26 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/originData/customer-who-visited-but-did-not-make-any-transactions.json
2023-12-09 19:57:46 +08:00

101 lines
13 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"data": {
"question": {
"questionId": "1724",
"questionFrontendId": "1581",
"categoryTitle": "Database",
"boundTopicId": 409412,
"title": "Customer Who Visited but Did Not Make Any Transactions",
"titleSlug": "customer-who-visited-but-did-not-make-any-transactions",
"content": "<p>Table: <code>Visits</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| visit_id | int |\n| customer_id | int |\n+-------------+---------+\nvisit_id is the column with unique values for this table.\nThis table contains information about the customers who visited the mall.\n</pre>\n\n<p>&nbsp;</p>\n\n<p>Table: <code>Transactions</code></p>\n\n<pre>\n+----------------+---------+\n| Column Name | Type |\n+----------------+---------+\n| transaction_id | int |\n| visit_id | int |\n| amount | int |\n+----------------+---------+\ntransaction_id is column with unique values for this table.\nThis table contains information about the transactions made during the visit_id.\n</pre>\n\n<p>&nbsp;</p>\n\n<p>Write a&nbsp;solution to find the IDs of the users who visited without making any transactions and the number of times they made these types of visits.</p>\n\n<p>Return the result table sorted 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> \nVisits\n+----------+-------------+\n| visit_id | customer_id |\n+----------+-------------+\n| 1 | 23 |\n| 2 | 9 |\n| 4 | 30 |\n| 5 | 54 |\n| 6 | 96 |\n| 7 | 54 |\n| 8 | 54 |\n+----------+-------------+\nTransactions\n+----------------+----------+--------+\n| transaction_id | visit_id | amount |\n+----------------+----------+--------+\n| 2 | 5 | 310 |\n| 3 | 5 | 300 |\n| 9 | 5 | 200 |\n| 12 | 1 | 910 |\n| 13 | 2 | 970 |\n+----------------+----------+--------+\n<strong>Output:</strong> \n+-------------+----------------+\n| customer_id | count_no_trans |\n+-------------+----------------+\n| 54 | 2 |\n| 30 | 1 |\n| 96 | 1 |\n+-------------+----------------+\n<strong>Explanation:</strong> \nCustomer with id = 23 visited the mall once and made one transaction during the visit with id = 12.\nCustomer with id = 9 visited the mall once and made one transaction during the visit with id = 13.\nCustomer with id = 30 visited the mall once and did not make any transactions.\nCustomer with id = 54 visited the mall three times. During 2 visits they did not make any transactions, and during one visit they made 3 transactions.\nCustomer with id = 96 visited the mall once and did not make any transactions.\nAs we can see, users with IDs 30 and 96 visited the mall one time without making any transactions. Also, user 54 visited the mall twice and did not make any transactions.\n</pre>\n",
"translatedTitle": "进店却未进行过交易的顾客",
"translatedContent": "<p>表:<code>Visits</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| visit_id | int |\n| customer_id | int |\n+-------------+---------+\nvisit_id 是该表中具有唯一值的列。\n该表包含有关光临过购物中心的顾客的信息。\n</pre>\n\n<p>&nbsp;</p>\n\n<p>表:<code>Transactions</code></p>\n\n<pre>\n+----------------+---------+\n| Column Name | Type |\n+----------------+---------+\n| transaction_id | int |\n| visit_id | int |\n| amount | int |\n+----------------+---------+\ntransaction_id 是该表中具有唯一值的列。\n此表包含 visit_id 期间进行的交易的信息。\n</pre>\n\n<p>&nbsp;</p>\n\n<p>有一些顾客可能光顾了购物中心但没有进行交易。请你编写一个解决方案,来查找这些顾客的 ID ,以及他们只光顾不交易的次数。</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<code><strong>输入:</strong>\nVisits</code>\n+----------+-------------+\n| visit_id | customer_id |\n+----------+-------------+\n| 1 | 23 |\n| 2 | 9 |\n| 4 | 30 |\n| 5 | 54 |\n| 6 | 96 |\n| 7 | 54 |\n| 8 | 54 |\n+----------+-------------+\n<code>Transactions</code>\n+----------------+----------+--------+\n| transaction_id | visit_id | amount |\n+----------------+----------+--------+\n| 2 | 5 | 310 |\n| 3 | 5 | 300 |\n| 9 | 5 | 200 |\n| 12 | 1 | 910 |\n| 13 | 2 | 970 |\n+----------------+----------+--------+\n<b>输出:</b>\n+-------------+----------------+\n| customer_id | count_no_trans |\n+-------------+----------------+\n| 54 | 2 |\n| 30 | 1 |\n| 96 | 1 |\n+-------------+----------------+\n<b>解释:</b>\nID = 23 的顾客曾经逛过一次购物中心,并在 ID = 12 的访问期间进行了一笔交易。\nID = 9 的顾客曾经逛过一次购物中心,并在 ID = 13 的访问期间进行了一笔交易。\nID = 30 的顾客曾经去过购物中心,并且没有进行任何交易。\nID = 54 的顾客三度造访了购物中心。在 2 次访问中,他们没有进行任何交易,在 1 次访问中,他们进行了 3 次交易。\nID = 96 的顾客曾经去过购物中心,并且没有进行任何交易。\n如我们所见ID 为 30 和 96 的顾客一次没有进行任何交易就去了购物中心。顾客 54 也两次访问了购物中心并且没有进行任何交易。</pre>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 147,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"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}",
"topicTags": [
{
"name": "Database",
"slug": "database",
"translatedName": "数据库",
"__typename": "TopicTagNode"
}
],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "MySQL",
"langSlug": "mysql",
"code": "# Write your MySQL query statement below",
"__typename": "CodeSnippetNode"
},
{
"lang": "MS SQL Server",
"langSlug": "mssql",
"code": "/* Write your T-SQL query statement below */",
"__typename": "CodeSnippetNode"
},
{
"lang": "Oracle",
"langSlug": "oraclesql",
"code": "/* Write your PL/SQL query statement below */",
"__typename": "CodeSnippetNode"
},
{
"lang": "Pandas",
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef find_customers(visits: pd.DataFrame, transactions: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
},
{
"lang": "PostgreSQL",
"langSlug": "postgresql",
"code": "-- Write your PostgreSQL query statement below",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"64.6K\", \"totalSubmission\": \"85.5K\", \"totalAcceptedRaw\": 64576, \"totalSubmissionRaw\": 85487, \"acRate\": \"75.5%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"Visits\":[\"visit_id\",\"customer_id\"],\"Transactions\":[\"transaction_id\",\"visit_id\",\"amount\"]},\"rows\":{\"Visits\":[[1,23],[2,9],[4,30],[5,54],[6,96],[7,54],[8,54]],\"Transactions\":[[2,5,310],[3,5,300],[9,5,200],[12,1,910],[13,2,970]]}}",
"metaData": "{\"mysql\":[\"Create table If Not Exists Visits(visit_id int, customer_id int)\",\"Create table If Not Exists Transactions(transaction_id int, visit_id int, amount int)\"],\"mssql\":[\"Create table Visits(visit_id int, customer_id int)\",\"Create table Transactions(transaction_id int, visit_id int, amount int)\"],\"oraclesql\":[\"Create table Visits(visit_id int, customer_id int)\",\"Create table Transactions(transaction_id int, visit_id int, amount int)\"],\"database\":true,\"name\":\"find_customers\",\"pythondata\":[\"Visits = pd.DataFrame([], columns=['visit_id', 'customer_id']).astype({'visit_id':'Int64', 'customer_id':'Int64'})\",\"Transactions = pd.DataFrame([], columns=['transaction_id', 'visit_id', 'amount']).astype({'transaction_id':'Int64', 'visit_id':'Int64', 'amount':'Int64'})\\n\"],\"postgresql\":[\"\\nCreate table If Not Exists Visits(visit_id int, customer_id int)\\n\",\"Create table If Not Exists Transactions(transaction_id int, visit_id int, amount int)\"],\"database_schema\":{\"Visits\":{\"visit_id\":\"INT\",\"customer_id\":\"INT\"},\"Transactions\":{\"transaction_id\":\"INT\",\"visit_id\":\"INT\",\"amount\":\"INT\"}}}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table If Not Exists Visits(visit_id int, customer_id int)",
"Create table If Not Exists Transactions(transaction_id int, visit_id int, amount int)",
"Truncate table Visits",
"insert into Visits (visit_id, customer_id) values ('1', '23')",
"insert into Visits (visit_id, customer_id) values ('2', '9')",
"insert into Visits (visit_id, customer_id) values ('4', '30')",
"insert into Visits (visit_id, customer_id) values ('5', '54')",
"insert into Visits (visit_id, customer_id) values ('6', '96')",
"insert into Visits (visit_id, customer_id) values ('7', '54')",
"insert into Visits (visit_id, customer_id) values ('8', '54')",
"Truncate table Transactions",
"insert into Transactions (transaction_id, visit_id, amount) values ('2', '5', '310')",
"insert into Transactions (transaction_id, visit_id, amount) values ('3', '5', '300')",
"insert into Transactions (transaction_id, visit_id, amount) values ('9', '5', '200')",
"insert into Transactions (transaction_id, visit_id, amount) values ('12', '1', '910')",
"insert into Transactions (transaction_id, visit_id, amount) values ('13', '2', '970')"
],
"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>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"Visits\":[\"visit_id\",\"customer_id\"],\"Transactions\":[\"transaction_id\",\"visit_id\",\"amount\"]},\"rows\":{\"Visits\":[[1,23],[2,9],[4,30],[5,54],[6,96],[7,54],[8,54]],\"Transactions\":[[2,5,310],[3,5,300],[9,5,200],[12,1,910],[13,2,970]]}}",
"__typename": "QuestionNode"
}
}
}