{ "data": { "question": { "questionId": "584", "questionFrontendId": "584", "boundTopicId": null, "title": "Find Customer Referee", "titleSlug": "find-customer-referee", "content": "

Table: Customer

\n\n
\n+-------------+---------+\n| Column Name | Type    |\n+-------------+---------+\n| id          | int     |\n| name        | varchar |\n| referee_id  | int     |\n+-------------+---------+\nid is the primary key column for this table.\nEach row of this table indicates the id of a customer, their name, and the id of the customer who referred them.\n
\n\n

 

\n\n

Write an SQL query to report the IDs of the customer that are not referred by the customer with id = 2.

\n\n

Return the result table in any order.

\n\n

The query result format is in the following example.

\n\n

 

\n

Example 1:

\n\n
\nInput: \nCustomer table:\n+----+------+------------+\n| id | name | referee_id |\n+----+------+------------+\n| 1  | Will | null       |\n| 2  | Jane | null       |\n| 3  | Alex | 2          |\n| 4  | Bill | null       |\n| 5  | Zack | 1          |\n| 6  | Mark | 2          |\n+----+------+------------+\nOutput: \n+------+\n| name |\n+------+\n| Will |\n| Jane |\n| Bill |\n| Zack |\n+------+\n
\n", "translatedTitle": null, "translatedContent": null, "isPaidOnly": false, "difficulty": "Easy", "likes": 214, "dislikes": 134, "isLiked": null, "similarQuestions": "[]", "exampleTestcases": "{\"headers\":{\"Customer\":[\"id\",\"name\",\"referee_id\"]},\"rows\":{\"Customer\":[[1,\"Will\",null],[2,\"Jane\",null],[3,\"Alex\",2],[4,\"Bill\",null],[5,\"Zack\",1],[6,\"Mark\",2]]}}", "categoryTitle": "Database", "contributors": [], "topicTags": [ { "name": "Database", "slug": "database", "translatedName": null, "__typename": "TopicTagNode" } ], "companyTagStats": null, "codeSnippets": [ { "lang": "MySQL", "langSlug": "mysql", "code": "# Write your MySQL query statement below\n", "__typename": "CodeSnippetNode" }, { "lang": "MS SQL Server", "langSlug": "mssql", "code": "/* Write your T-SQL query statement below */\n", "__typename": "CodeSnippetNode" }, { "lang": "Oracle", "langSlug": "oraclesql", "code": "/* Write your PL/SQL query statement below */\n", "__typename": "CodeSnippetNode" } ], "stats": "{\"totalAccepted\": \"65.3K\", \"totalSubmission\": \"84.9K\", \"totalAcceptedRaw\": 65278, \"totalSubmissionRaw\": 84891, \"acRate\": \"76.9%\"}", "hints": [ "Be careful of the NULL value" ], "solution": { "id": "156", "canSeeDetail": true, "paidOnly": false, "hasVideoSolution": false, "paidOnlyVideo": true, "__typename": "ArticleNode" }, "status": null, "sampleTestCase": "{\"headers\":{\"Customer\":[\"id\",\"name\",\"referee_id\"]},\"rows\":{\"Customer\":[[1,\"Will\",null],[2,\"Jane\",null],[3,\"Alex\",2],[4,\"Bill\",null],[5,\"Zack\",1],[6,\"Mark\",2]]}}", "metaData": "{\n \"mysql\": [\n \"Create table If Not Exists Customer (id int, name varchar(25), referee_id int)\"\n ],\n \"mssql\": [\n \"Create table Customer (id int, name varchar(25), referee_id int)\"\n ],\n \"oraclesql\": [\n \"Create table Customer (id int, name varchar(25), referee_id int)\"\n ],\n \"database\": true\n}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [ "Create table If Not Exists Customer (id int, name varchar(25), referee_id int)", "Truncate table Customer", "insert into Customer (id, name, referee_id) values ('1', 'Will', 'None')", "insert into Customer (id, name, referee_id) values ('2', 'Jane', 'None')", "insert into Customer (id, name, referee_id) values ('3', 'Alex', '2')", "insert into Customer (id, name, referee_id) values ('4', 'Bill', 'None')", "insert into Customer (id, name, referee_id) values ('5', 'Zack', '1')", "insert into Customer (id, name, referee_id) values ('6', 'Mark', '2')" ], "enableRunCode": true, "enableTestMode": false, "enableDebugger": false, "envInfo": "{\"mysql\": [\"MySQL\", \"

MySQL 8.0.

\"], \"mssql\": [\"MS SQL Server\", \"

mssql server 2019.

\"], \"oraclesql\": [\"Oracle\", \"

Oracle Sql 11.2.

\"]}", "libraryUrl": null, "adminUrl": null, "challengeQuestion": null, "__typename": "QuestionNode" } } }