mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
94 lines
9.7 KiB
JSON
94 lines
9.7 KiB
JSON
{
|
||
"data": {
|
||
"question": {
|
||
"questionId": "1625",
|
||
"questionFrontendId": "1484",
|
||
"categoryTitle": "Database",
|
||
"boundTopicId": 293060,
|
||
"title": "Group Sold Products By The Date",
|
||
"titleSlug": "group-sold-products-by-the-date",
|
||
"content": "<p>Table <code>Activities</code>:</p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| sell_date | date |\n| product | varchar |\n+-------------+---------+\nThere is no primary key (column with unique values) for this table. It may contain duplicates.\nEach row of this table contains the product name and the date it was sold in a market.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to find for each date the number of different products sold and their names.</p>\n\n<p>The sold products names for each date should be sorted lexicographically.</p>\n\n<p>Return the result table ordered by <code>sell_date</code>.</p>\n\n<p>The result format is in the following example.</p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nActivities table:\n+------------+------------+\n| sell_date | product |\n+------------+------------+\n| 2020-05-30 | Headphone |\n| 2020-06-01 | Pencil |\n| 2020-06-02 | Mask |\n| 2020-05-30 | Basketball |\n| 2020-06-01 | Bible |\n| 2020-06-02 | Mask |\n| 2020-05-30 | T-Shirt |\n+------------+------------+\n<strong>Output:</strong> \n+------------+----------+------------------------------+\n| sell_date | num_sold | products |\n+------------+----------+------------------------------+\n| 2020-05-30 | 3 | Basketball,Headphone,T-shirt |\n| 2020-06-01 | 2 | Bible,Pencil |\n| 2020-06-02 | 1 | Mask |\n+------------+----------+------------------------------+\n<strong>Explanation:</strong> \nFor 2020-05-30, Sold items were (Headphone, Basketball, T-shirt), we sort them lexicographically and separate them by a comma.\nFor 2020-06-01, Sold items were (Pencil, Bible), we sort them lexicographically and separate them by a comma.\nFor 2020-06-02, the Sold item is (Mask), we just return it.\n</pre>\n",
|
||
"translatedTitle": "按日期分组销售产品",
|
||
"translatedContent": "<p>表 <code>Activities</code>:</p>\n\n<pre>\n+-------------+---------+\n| 列名 | 类型 |\n+-------------+---------+\n| sell_date | date |\n| product | varchar |\n+-------------+---------+\n该表没有主键(具有唯一值的列)。它可能包含重复项。\n此表的每一行都包含产品名称和在市场上销售的日期。\n</pre>\n\n<p> </p>\n\n<p>编写解决方案找出每个日期、销售的不同产品的数量及其名称。<br />\n每个日期的销售产品名称应按词典序排列。<br />\n返回按 <code>sell_date</code> 排序的结果表。<br />\n结果表结果格式如下例所示。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<code><strong>输入:</strong>\nActivities</code> 表:\n+------------+-------------+\n| sell_date | product |\n+------------+-------------+\n| 2020-05-30 | Headphone |\n| 2020-06-01 | Pencil |\n| 2020-06-02 | Mask |\n| 2020-05-30 | Basketball |\n| 2020-06-01 | Bible |\n| 2020-06-02 | Mask |\n| 2020-05-30 | T-Shirt |\n+------------+-------------+\n<strong>输出:</strong>\n+------------+----------+------------------------------+\n| sell_date | num_sold | products |\n+------------+----------+------------------------------+\n| 2020-05-30 | 3 | Basketball,Headphone,T-shirt |\n| 2020-06-01 | 2 | Bible,Pencil |\n| 2020-06-02 | 1 | Mask |\n+------------+----------+------------------------------+\n<strong>解释:</strong>\n对于2020-05-30,出售的物品是 (Headphone, Basketball, T-shirt),按词典序排列,并用逗号 ',' 分隔。\n对于2020-06-01,出售的物品是 (Pencil, Bible),按词典序排列,并用逗号分隔。\n对于2020-06-02,出售的物品是 (Mask),只需返回该物品名。\n</pre>\n",
|
||
"isPaidOnly": false,
|
||
"difficulty": "Easy",
|
||
"likes": 205,
|
||
"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 categorize_products(activities: pd.DataFrame) -> pd.DataFrame:\n ",
|
||
"__typename": "CodeSnippetNode"
|
||
},
|
||
{
|
||
"lang": "PostgreSQL",
|
||
"langSlug": "postgresql",
|
||
"code": "-- Write your PostgreSQL query statement below",
|
||
"__typename": "CodeSnippetNode"
|
||
}
|
||
],
|
||
"stats": "{\"totalAccepted\": \"63.2K\", \"totalSubmission\": \"92.6K\", \"totalAcceptedRaw\": 63218, \"totalSubmissionRaw\": 92615, \"acRate\": \"68.3%\"}",
|
||
"hints": [],
|
||
"solution": null,
|
||
"status": null,
|
||
"sampleTestCase": "{\"headers\":{\"Activities\":[\"sell_date\",\"product\"]},\"rows\":{\"Activities\":[[\"2020-05-30\",\"Headphone\"],[\"2020-06-01\",\"Pencil\"],[\"2020-06-02\",\"Mask\"],[\"2020-05-30\",\"Basketball\"],[\"2020-06-01\",\"Bible\"],[\"2020-06-02\",\"Mask\"],[\"2020-05-30\",\"T-Shirt\"]]}}",
|
||
"metaData": "{\"mysql\":[\"Create table If Not Exists Activities (sell_date date, product varchar(20))\"],\"mssql\":[\"Create table Activities (sell_date date, product varchar(20))\"],\"oraclesql\":[\"Create table Activities (sell_date date, product varchar(20))\",\"ALTER SESSION SET nls_date_format='YYYY-MM-DD'\"],\"database\":true,\"name\":\"categorize_products\",\"pythondata\":[\"Activities = pd.DataFrame([], columns=['sell_date', 'product']).astype({'sell_date':'datetime64[ns]', 'product':'object'})\"],\"manual\":false,\"postgresql\":[\"\\nCreate table If Not Exists Activities (sell_date date, product varchar(20))\"],\"database_schema\":{\"Activities\":{\"sell_date\":\"DATE\",\"product\":\"VARCHAR(20)\"}}}",
|
||
"judgerAvailable": true,
|
||
"judgeType": "large",
|
||
"mysqlSchemas": [
|
||
"Create table If Not Exists Activities (sell_date date, product varchar(20))",
|
||
"Truncate table Activities",
|
||
"insert into Activities (sell_date, product) values ('2020-05-30', 'Headphone')",
|
||
"insert into Activities (sell_date, product) values ('2020-06-01', 'Pencil')",
|
||
"insert into Activities (sell_date, product) values ('2020-06-02', 'Mask')",
|
||
"insert into Activities (sell_date, product) values ('2020-05-30', 'Basketball')",
|
||
"insert into Activities (sell_date, product) values ('2020-06-01', 'Bible')",
|
||
"insert into Activities (sell_date, product) values ('2020-06-02', 'Mask')",
|
||
"insert into Activities (sell_date, product) values ('2020-05-30', 'T-Shirt')"
|
||
],
|
||
"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\":{\"Activities\":[\"sell_date\",\"product\"]},\"rows\":{\"Activities\":[[\"2020-05-30\",\"Headphone\"],[\"2020-06-01\",\"Pencil\"],[\"2020-06-02\",\"Mask\"],[\"2020-05-30\",\"Basketball\"],[\"2020-06-01\",\"Bible\"],[\"2020-06-02\",\"Mask\"],[\"2020-05-30\",\"T-Shirt\"]]}}",
|
||
"__typename": "QuestionNode"
|
||
}
|
||
}
|
||
} |