2022-03-27 20:46:41 +08:00
{
"data" : {
"question" : {
"questionId" : "607" ,
"questionFrontendId" : "607" ,
"categoryTitle" : "Database" ,
"boundTopicId" : 2638 ,
"title" : "Sales Person" ,
"titleSlug" : "sales-person" ,
2023-12-09 18:42:21 +08:00
"content" : "<p>Table: <code>SalesPerson</code></p>\n\n<pre>\n+-----------------+---------+\n| Column Name | Type |\n+-----------------+---------+\n| sales_id | int |\n| name | varchar |\n| salary | int |\n| commission_rate | int |\n| hire_date | date |\n+-----------------+---------+\nsales_id is the primary key (column with unique values) for this table.\nEach row of this table indicates the name and the ID of a salesperson alongside their salary, commission rate, and hire date.\n</pre>\n\n<p> </p>\n\n<p>Table: <code>Company</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| com_id | int |\n| name | varchar |\n| city | varchar |\n+-------------+---------+\ncom_id is the primary key (column with unique values) for this table.\nEach row of this table indicates the name and the ID of a company and the city in which the company is located.\n</pre>\n\n<p> </p>\n\n<p>Table: <code>Orders</code></p>\n\n<pre>\n+-------------+------+\n| Column Name | Type |\n+-------------+------+\n| order_id | int |\n| order_date | date |\n| com_id | int |\n| sales_id | int |\n| amount | int |\n+-------------+------+\norder_id is the primary key (column with unique values) for this table.\ncom_id is a foreign key (reference column) to com_id from the Company table.\nsales_id is a foreign key (reference column) to sales_id from the SalesPerson table.\nEach row of this table contains information about one order. This includes the ID of the company, the ID of the salesperson, the date of the order, and the amount paid.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to find the names of all the salespersons who did not have any orders related to the company with the name <strong>"RED"</strong>.</p>\n\n<p>Return the result table in <strong>any order</strong>.</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> \nSalesPerson table:\n+----------+------+--------+-----------------+------------+\n| sales_id | name | salary | commission_rate | hire_date |\n+----------+------+--------+-----------------+------------+\n| 1 | John | 100000 | 6 | 4/1/2006 |\n| 2 | Amy | 12000 | 5 | 5/1/2010 |\n| 3 | Mark | 65000 | 12 | 12/25/2008 |\n| 4 | Pam | 25000 | 25 | 1/1/2005 |\n| 5 | Alex | 5000 | 10 | 2/3/2007 |\n+----------+------+--------+-----------------+------------+\nCompany table:\n+--------+--------+----------+\n| com_id | name | city |\n+--------+--------+----------+\n| 1 | RED | Boston |\n| 2 | ORANGE | New York |\n| 3 | YELLOW | Boston |\n| 4 | GREEN | Austin |\n+--------+--------+----------+\nOrders table:\n+----------+------------+--------+----------+--------+\n| order_id | order_date | com_id | sales_id | amount |\n+----------+------------+--------+----------+--------+\n| 1 | 1/1/2014 | 3 | 4 | 10000 |\n| 2 | 2/1/2014 | 4 | 5 | 5000 |\n| 3 | 3/1/2014 | 1 | 1 | 50000 |\n| 4 | 4/1/2014 | 1 | 4 | 25000 |\n+----------+------------+--------+----------+--------+\n<strong>Output:</strong> \n+------+\n| name |\n+------+\n| Amy |\n| Mark |\n| Alex |\n+------+\n<strong>Explanation:</strong> \nAccording to orders 3 and 4 in the Orders table, it is easy to tell that only salesperson John and Pam have sales to company RED, so we report all the other names in the table salesperson.\n</pre>\n" ,
2022-03-27 20:46:41 +08:00
"translatedTitle" : "销售员" ,
2023-12-09 18:42:21 +08:00
"translatedContent" : "<p>表: <code>SalesPerson</code></p>\n\n<pre>\n+-----------------+---------+\n| Column Name | Type |\n+-----------------+---------+\n| sales_id | int |\n| name | varchar |\n| salary | int |\n| commission_rate | int |\n| hire_date | date |\n+-----------------+---------+\nsales_id 是该表的主键列(具有唯一值的列)。\n该表的每一行都显示了销售人员的姓名和 ID ,以及他们的工资、佣金率和雇佣日期。\n</pre>\n\n<p> </p>\n\n<p>表: <code>Company</code></p>\n\n<pre>\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| com_id | int |\n| name | varchar |\n| city | varchar |\n+-------------+---------+\ncom_id 是该表的主键列(具有唯一值的列)。\n该表的每一行都表示公司的名称和 ID ,以及公司所在的城市。\n</pre>\n\n<p> </p>\n\n<p>表: <code>Orders</code></p>\n\n<pre>\n+-------------+------+\n| Column Name | Type |\n+-------------+------+\n| order_id | int |\n| order_date | date |\n| com_id | int |\n| sales_id | int |\n| amount | int |\n+-------------+------+\norder_id 是该表的主键列(具有唯一值的列)。\ncom_id 是 Company 表中 com_id 的外键( reference 列)。\nsales_id 是来自销售员表 sales_id 的外键( reference 列)。\n该表的每一行包含一个订单的信息。这包括公司的 ID 、销售人员的 ID 、订单日期和支付的金额。\n</pre>\n\n<p> </p>\n\n<p>编写解决方案,找出没有任何与名为 <strong>“RED”</strong> 的公司相关的订单的所有销售人员的姓名。</p>\n\n<p>以 <strong>任意顺序</strong> 返回结果表。</p>\n\n<p>返回结果格式如下所示。</p>\n\n<p> </p>\n\n<p><strong>示例 1: </strong></p>\n\n<pre>\n<strong>输入:</strong>\nSalesPerson 表:\n+----------+------+--------+-----------------+------------+\n| sales_id | name | salary | commission_rate | hire_date |\n+----------+------+--------+-----------------+------------+\n| 1 | John | 100000 | 6 | 4/1/2006 |\n| 2 | Amy | 12000 | 5 | 5/1/2010 |\n| 3 | Mark | 65000 | 12 | 12/25/2008 |\n| 4 | Pam | 25000 | 25 | 1/1/2005 |\n| 5 | Alex | 5000 | 10 | 2/3/2007 |\n+----------+------+--------+-----------------+------------+\nCompany 表:\n+--------+--------+----------+\n| com_id | name | city |\n+--------+--------+----------+\n| 1 | RED | Boston |\n| 2 | ORANGE | New York |\n| 3 | YELLOW | Boston |\n| 4 | GREEN | Austin |\n+--------+--------+----------+\nOrders 表:\n+----------+------------+--------+----------+--------+\n| order_id | order_date | com_id | sales_id | amount |\n+----------+------------+--------+----------+--------+\n| 1 | 1/1/2014 | 3 | 4 | 10000 |\n| 2 | 2/1/2014 | 4 | 5 | 5000 |\n| 3 | 3/1/2014 | 1 | 1 | 50000 |\n| 4 | 4/1/2014 | 1 | 4 | 25000 |\n+----------+------------+--------+----------+--------+\n<strong>输出:</strong>\n+------+\n| name |\n+------+\n| Amy |\n| Mark |\n| Alex |\n+------+\n<strong>解释:</strong>\n根据表 <code>orders</code> 中的订单 '3' 和 '4' ,容易看出只有 'John' 和 'Pam' 两个销售员曾经向公司 'RED' 销售过。\n所以我们需要输出表 <code>salesperson</code> 中所有其他人的名字。</pre>\n" ,
2022-03-27 20:46:41 +08:00
"isPaidOnly" : false ,
"difficulty" : "Easy" ,
2023-12-09 18:42:21 +08:00
"likes" : 168 ,
2022-03-27 20:46:41 +08:00
"dislikes" : 0 ,
"isLiked" : null ,
"similarQuestions" : "[]" ,
"contributors" : [ ] ,
2023-12-09 18:42:21 +08:00
"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}" ,
2022-03-27 20:46:41 +08:00
"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"
2023-12-09 18:42:21 +08:00
} ,
{
"lang" : "Pandas" ,
"langSlug" : "pythondata" ,
"code" : "import pandas as pd\n\ndef sales_person(sales_person: pd.DataFrame, company: pd.DataFrame, orders: pd.DataFrame) -> pd.DataFrame:\n " ,
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "PostgreSQL" ,
"langSlug" : "postgresql" ,
"code" : "-- Write your PostgreSQL query statement below" ,
"__typename" : "CodeSnippetNode"
2022-03-27 20:46:41 +08:00
}
] ,
2023-12-09 19:57:46 +08:00
"stats" : "{\"totalAccepted\": \"80.9K\", \"totalSubmission\": \"120.8K\", \"totalAcceptedRaw\": 80942, \"totalSubmissionRaw\": 120838, \"acRate\": \"67.0%\"}" ,
2022-03-27 20:46:41 +08:00
"hints" : [
"You need to query who sold to company 'RED' first, then output the sales person who is not in the first query result."
] ,
"solution" : null ,
"status" : null ,
"sampleTestCase" : "{\"headers\": {\"SalesPerson\": [\"sales_id\", \"name\", \"salary\", \"commission_rate\",\"hire_date\"], \"Company\": [\"com_id\", \"name\",\"city\"],\"Orders\":[\"order_id\",\"order_date\",\"com_id\",\"sales_id\",\"amount\"]}, \"rows\": {\"SalesPerson\": [[1, \"John\", 100000, 6, \"4/1/2006\"], [2, \"Amy\", 12000, 5,\"5/1/2010\"], [3, \"Mark\", 65000, 12, \"12/25/2008\"], [4, \"Pam\", 25000, 25,\"1/1/2005\"],[5,\"Alex\",5000,10,\"2/3/2007\"]], \"Company\": [[1, \"RED\",\"Boston\"], [2, \"ORANGE\", \"New York\"],[3, \"YELLOW\", \"Boston\"],[4, \"GREEN\", \"Austin\"]],\"Orders\":[[1,\"1/1/2014\",3,4,10000],[2, \"2/1/2014\", 4, 5, 5000],[3, \"3/1/2014\", 1, 1, 50000],[4, \"4/1/2014\", 1, 4, 25000]]}}" ,
2023-12-09 18:42:21 +08:00
"metaData" : "{\"mysql\":[\"Create table If Not Exists SalesPerson (sales_id int, name varchar(255), salary int, commission_rate int, hire_date date)\",\"Create table If Not Exists Company (com_id int, name varchar(255), city varchar(255))\",\"Create table If Not Exists Orders (order_id int, order_date date, com_id int, sales_id int, amount int)\"],\"mssql\":[\"Create table SalesPerson (sales_id int, name varchar(255), salary int, commission_rate int, hire_date date)\",\"Create table Company (com_id int, name varchar(255), city varchar(255))\",\"Create table Orders (order_id int, order_date date, com_id int, sales_id int, amount int)\"],\"oraclesql\":[\"Create table SalesPerson (sales_id int, name varchar(255), salary int, commission_rate int, hire_date date)\",\"Create table Company (com_id int, name varchar(255), city varchar(255))\",\"Create table Orders (order_id int, order_date date, com_id int, sales_id int, amount int)\",\"Alter SESSION set NLS_DATE_FORMAT = 'MM\\/DD\\/YYYY'\"],\"database\":true,\"name\":\"sales_person\",\"pythondata\":[\"SalesPerson = pd.DataFrame([], columns=['sales_id', 'name', 'salary', 'commission_rate', 'hire_date']).astype({'sales_id':'Int64', 'name':'object', 'salary':'Int64', 'commission_rate':'Int64', 'hire_date':'datetime64[ns]'})\",\"Company = pd.DataFrame([], columns=['com_id', 'name', 'city']).astype({'com_id':'Int64', 'name':'object', 'city':'object'})\",\"Orders = pd.DataFrame([], columns=['order_id', 'order_date', 'com_id', 'sales_id', 'amount']).astype({'order_id':'Int64', 'order_date':'datetime64[ns]', 'com_id':'Int64', 'sales_id':'Int64', 'amount':'Int64'})\\n\"],\"manual\":false,\"postgresql\":[\"Create table If Not Exists SalesPerson (sales_id int, name varchar(255), salary int, commission_rate int, hire_date date)\",\"Create table If Not Exists Company (com_id int, name varchar(255), city varchar(255))\\n\",\"Create table If Not Exists Orders (order_id int, order_date date, com_id int, sales_id int, amount int)\"],\"database_schema\":{\"SalesPerson\":{\"sales_id\":\"INT\",\"name\":\"VARCHAR(255)\",\"salary\":\"INT\",\"commission_rate\":\"INT\",\"hire_date\":\"DATE\"},\"Company\":{\"com_id\":\"INT\",\"name\":\"VARCHAR(255)\",\"city\":\"VARCHAR(255)\"},\"Orders\":{\"order_id\":\"INT\",\"order_date\":\"DATE\",\"com_id\":\"INT\",\"sales_id\":\"INT\",\"amount\":\"INT\"}}}" ,
2022-03-27 20:46:41 +08:00
"judgerAvailable" : true ,
"judgeType" : "large" ,
"mysqlSchemas" : [
"Create table If Not Exists SalesPerson (sales_id int, name varchar(255), salary int, commission_rate int, hire_date date)" ,
"Create table If Not Exists Company (com_id int, name varchar(255), city varchar(255))" ,
"Create table If Not Exists Orders (order_id int, order_date date, com_id int, sales_id int, amount int)" ,
"Truncate table SalesPerson" ,
"insert into SalesPerson (sales_id, name, salary, commission_rate, hire_date) values ('1', 'John', '100000', '6', '4/1/2006')" ,
"insert into SalesPerson (sales_id, name, salary, commission_rate, hire_date) values ('2', 'Amy', '12000', '5', '5/1/2010')" ,
"insert into SalesPerson (sales_id, name, salary, commission_rate, hire_date) values ('3', 'Mark', '65000', '12', '12/25/2008')" ,
"insert into SalesPerson (sales_id, name, salary, commission_rate, hire_date) values ('4', 'Pam', '25000', '25', '1/1/2005')" ,
"insert into SalesPerson (sales_id, name, salary, commission_rate, hire_date) values ('5', 'Alex', '5000', '10', '2/3/2007')" ,
"Truncate table Company" ,
"insert into Company (com_id, name, city) values ('1', 'RED', 'Boston')" ,
"insert into Company (com_id, name, city) values ('2', 'ORANGE', 'New York')" ,
"insert into Company (com_id, name, city) values ('3', 'YELLOW', 'Boston')" ,
"insert into Company (com_id, name, city) values ('4', 'GREEN', 'Austin')" ,
"Truncate table Orders" ,
"insert into Orders (order_id, order_date, com_id, sales_id, amount) values ('1', '1/1/2014', '3', '4', '10000')" ,
"insert into Orders (order_id, order_date, com_id, sales_id, amount) values ('2', '2/1/2014', '4', '5', '5000')" ,
"insert into Orders (order_id, order_date, com_id, sales_id, amount) values ('3', '3/1/2014', '1', '1', '50000')" ,
"insert into Orders (order_id, order_date, com_id, sales_id, amount) values ('4', '4/1/2014', '1', '4', '25000')"
] ,
"enableRunCode" : true ,
2023-12-09 18:42:21 +08:00
"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>\"]}" ,
2022-03-27 20:46:41 +08:00
"book" : null ,
"isSubscribed" : false ,
"isDailyQuestion" : false ,
"dailyRecordStatus" : null ,
"editorType" : "CKEDITOR" ,
"ugcQuestionId" : null ,
"style" : "LEETCODE" ,
"exampleTestcases" : "{\"headers\": {\"SalesPerson\": [\"sales_id\", \"name\", \"salary\", \"commission_rate\",\"hire_date\"], \"Company\": [\"com_id\", \"name\",\"city\"],\"Orders\":[\"order_id\",\"order_date\",\"com_id\",\"sales_id\",\"amount\"]}, \"rows\": {\"SalesPerson\": [[1, \"John\", 100000, 6, \"4/1/2006\"], [2, \"Amy\", 12000, 5,\"5/1/2010\"], [3, \"Mark\", 65000, 12, \"12/25/2008\"], [4, \"Pam\", 25000, 25,\"1/1/2005\"],[5,\"Alex\",5000,10,\"2/3/2007\"]], \"Company\": [[1, \"RED\",\"Boston\"], [2, \"ORANGE\", \"New York\"],[3, \"YELLOW\", \"Boston\"],[4, \"GREEN\", \"Austin\"]],\"Orders\":[[1,\"1/1/2014\",3,4,10000],[2, \"2/1/2014\", 4, 5, 5000],[3, \"3/1/2014\", 1, 1, 50000],[4, \"4/1/2014\", 1, 4, 25000]]}}" ,
"__typename" : "QuestionNode"
}
}
}