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/group-sold-products-by-the-date.json
2022-05-02 23:44:12 +08:00

82 lines
8.6 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": "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 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>&nbsp;</p>\n\n<p>Write an SQL query 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 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> \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>表&nbsp;<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>&nbsp;</p>\n\n<p>编写一个 SQL 查询来查找每个日期、销售的不同产品的数量及其名称。<br />\n每个日期的销售产品名称应按词典序排列。<br />\n返回按&nbsp;<code>sell_date</code> 排序的结果表。<br />\n查询结果格式如下例所示。</p>\n\n<p>&nbsp;</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),只需返回该物品名。</pre>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 41,
"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"
}
],
"stats": "{\"totalAccepted\": \"9.5K\", \"totalSubmission\": \"13.9K\", \"totalAcceptedRaw\": 9452, \"totalSubmissionRaw\": 13883, \"acRate\": \"68.1%\"}",
"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": "{\n \"mysql\": [\n \"Create table If Not Exists Activities (sell_date date, product varchar(20))\"\n ],\n \"mssql\": [\n \"Create table Activities (sell_date date, product varchar(20))\"\n ],\n \"oraclesql\": [\n \"Create table Activities (sell_date date, product varchar(20))\",\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 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>\"]}",
"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"
}
}
}