1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/originData/daily-leads-and-partners.json

85 lines
11 KiB
JSON
Raw Normal View History

2022-03-27 20:45:09 +08:00
{
"data": {
"question": {
"questionId": "1837",
"questionFrontendId": "1693",
"categoryTitle": "Database",
"boundTopicId": 527580,
"title": "Daily Leads and Partners",
"titleSlug": "daily-leads-and-partners",
"content": "<p>Table: <code>DailySales</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| date_id | date |\n| make_name | varchar |\n| lead_id | int |\n| partner_id | int |\n+-------------+---------+\nThis table does not have a primary key.\nThis table contains the date and the name of the product sold and the IDs of the lead and partner it was sold to.\nThe name consists of only lowercase English letters.\n</pre>\n\n<p>&nbsp;</p>\n\n<p>Write an SQL query that will, for each <code>date_id</code> and <code>make_name</code>, return the number of <strong>distinct</strong> <code>lead_id</code>&#39;s and <strong>distinct</strong> <code>partner_id</code>&#39;s.</p>\n\n<p>Return the result table in <strong>any order</strong>.</p>\n\n<p>The query result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong>Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nDailySales table:\n+-----------+-----------+---------+------------+\n| date_id | make_name | lead_id | partner_id |\n+-----------+-----------+---------+------------+\n| 2020-12-8 | toyota | 0 | 1 |\n| 2020-12-8 | toyota | 1 | 0 |\n| 2020-12-8 | toyota | 1 | 2 |\n| 2020-12-7 | toyota | 0 | 2 |\n| 2020-12-7 | toyota | 0 | 1 |\n| 2020-12-8 | honda | 1 | 2 |\n| 2020-12-8 | honda | 2 | 1 |\n| 2020-12-7 | honda | 0 | 1 |\n| 2020-12-7 | honda | 1 | 2 |\n| 2020-12-7 | honda | 2 | 1 |\n+-----------+-----------+---------+------------+\n<strong>Output:</strong> \n+-----------+-----------+--------------+-----------------+\n| date_id | make_name | unique_leads | unique_partners |\n+-----------+-----------+--------------+-----------------+\n| 2020-12-8 | toyota | 2 | 3 |\n| 2020-12-7 | toyota | 1 | 2 |\n| 2020-12-8 | honda | 2 | 2 |\n| 2020-12-7 | honda | 3 | 2 |\n+-----------+-----------+--------------+-----------------+\n<strong>Explanation:</strong> \nFor 2020-12-8, toyota gets leads = [0, 1] and partners = [0, 1, 2] while honda gets leads = [1, 2] and partners = [1, 2].\nFor 2020-12-7, toyota gets leads = [0] and partners = [1, 2] while honda gets leads = [0, 1, 2] and partners = [1, 2].\n</pre>\n",
"translatedTitle": "每天的领导和合伙人",
"translatedContent": "<p>表:<code>DailySales</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| date_id | date |\n| make_name | varchar |\n| lead_id | int |\n| partner_id | int |\n+-------------+---------+\n该表没有主键。\n该表包含日期、产品的名称以及售给的领导和合伙人的编号。\n名称只包含小写英文字母。</pre>\n\n<p>&nbsp;</p>\n\n<p>写一条 SQL 语句,使得对于每一个&nbsp;<code>date_id</code>&nbsp;和&nbsp;<code>make_name</code>,返回<strong>不同</strong>的&nbsp;<code>lead_id</code>&nbsp;以及<strong>不同</strong>的&nbsp;<code>partner_id</code>&nbsp;的数量。</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>\nDailySales 表:\n+-----------+-----------+---------+------------+\n| date_id | make_name | lead_id | partner_id |\n+-----------+-----------+---------+------------+\n| 2020-12-8 | toyota | 0 | 1 |\n| 2020-12-8 | toyota | 1 | 0 |\n| 2020-12-8 | toyota | 1 | 2 |\n| 2020-12-7 | toyota | 0 | 2 |\n| 2020-12-7 | toyota | 0 | 1 |\n| 2020-12-8 | honda | 1 | 2 |\n| 2020-12-8 | honda | 2 | 1 |\n| 2020-12-7 | honda | 0 | 1 |\n| 2020-12-7 | honda | 1 | 2 |\n| 2020-12-7 | honda | 2 | 1 |\n+-----------+-----------+---------+------------+\n<strong>输出:</strong>\n+-----------+-----------+--------------+-----------------+\n| date_id | make_name | unique_leads | unique_partners |\n+-----------+-----------+--------------+-----------------+\n| 2020-12-8 | toyota | 2 | 3 |\n| 2020-12-7 | toyota | 1 | 2 |\n| 2020-12-8 | honda | 2 | 2 |\n| 2020-12-7 | honda | 3 | 2 |\n+-----------+-----------+--------------+-----------------+\n<strong>解释:</strong>\n在 2020-12-8丰田toyota有领导者 = [0, 1] 和合伙人 = [0, 1, 2] 同时本田honda有领导者 = [1, 2] 和合伙人 = [1, 2]。\n在 2020-12-7丰田toyota有领导者 = [0] 和合伙人 = [1, 2] 同时本田honda有领导者 = [0, 1, 2] 和合伙人 = [1, 2]。</pre>\n",
"isPaidOnly": false,
"difficulty": "Easy",
2022-05-02 23:44:12 +08:00
"likes": 9,
2022-03-27 20:45:09 +08:00
"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, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": 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"
}
],
2022-05-02 23:44:12 +08:00
"stats": "{\"totalAccepted\": \"5.4K\", \"totalSubmission\": \"6.6K\", \"totalAcceptedRaw\": 5387, \"totalSubmissionRaw\": 6592, \"acRate\": \"81.7%\"}",
2022-03-27 20:45:09 +08:00
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"DailySales\":[\"date_id\",\"make_name\",\"lead_id\",\"partner_id\"]},\"rows\":{\"DailySales\":[[\"2020-12-8\",\"toyota\",0,1],[\"2020-12-8\",\"toyota\",1,0],[\"2020-12-8\",\"toyota\",1,2],[\"2020-12-7\",\"toyota\",0,2],[\"2020-12-7\",\"toyota\",0,1],[\"2020-12-8\",\"honda\",1,2],[\"2020-12-8\",\"honda\",2,1],[\"2020-12-7\",\"honda\",0,1],[\"2020-12-7\",\"honda\",1,2],[\"2020-12-7\",\"honda\",2,1]]}}",
"metaData": "{\n \"mysql\": [\n \"Create table If Not Exists DailySales(date_id date, make_name varchar(20), lead_id int, partner_id int)\"\n ],\n \"mssql\": [\n \"Create table DailySales(date_id date, make_name varchar(20), lead_id int, partner_id int)\"\n ],\n \"oraclesql\": [\n \"Create table DailySales(date_id date, make_name varchar(20), lead_id int, partner_id int)\",\n \"ALTER SESSION SET nls_date_format='YYYY-MM-DD'\"\n ],\n \"database\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table If Not Exists DailySales(date_id date, make_name varchar(20), lead_id int, partner_id int)",
"Truncate table DailySales",
"insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-8', 'toyota', '0', '1')",
"insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-8', 'toyota', '1', '0')",
"insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-8', 'toyota', '1', '2')",
"insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-7', 'toyota', '0', '2')",
"insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-7', 'toyota', '0', '1')",
"insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-8', 'honda', '1', '2')",
"insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-8', 'honda', '2', '1')",
"insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-7', 'honda', '0', '1')",
"insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-7', 'honda', '1', '2')",
"insert into DailySales (date_id, make_name, lead_id, partner_id) values ('2020-12-7', 'honda', '2', '1')"
],
"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>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"DailySales\":[\"date_id\",\"make_name\",\"lead_id\",\"partner_id\"]},\"rows\":{\"DailySales\":[[\"2020-12-8\",\"toyota\",0,1],[\"2020-12-8\",\"toyota\",1,0],[\"2020-12-8\",\"toyota\",1,2],[\"2020-12-7\",\"toyota\",0,2],[\"2020-12-7\",\"toyota\",0,1],[\"2020-12-8\",\"honda\",1,2],[\"2020-12-8\",\"honda\",2,1],[\"2020-12-7\",\"honda\",0,1],[\"2020-12-7\",\"honda\",1,2],[\"2020-12-7\",\"honda\",2,1]]}}",
"__typename": "QuestionNode"
}
}
}