{ "data": { "question": { "questionId": "196", "questionFrontendId": "196", "boundTopicId": null, "title": "Delete Duplicate Emails", "titleSlug": "delete-duplicate-emails", "content": "
Table: Person
\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| id | int |\n| email | varchar |\n+-------------+---------+\nid is the primary key column for this table.\nEach row of this table contains an email. The emails will not contain uppercase letters.\n\n\n
\n\n
Write an SQL query to delete all the duplicate emails, keeping only one unique email with the smallest id
. Note that you are supposed to write a DELETE
statement and not a SELECT
one.
Return the result table in any order.
\n\nThe query result format is in the following example.
\n\n\n
Example 1:
\n\n\nInput: \nPerson table:\n+----+------------------+\n| id | email |\n+----+------------------+\n| 1 | john@example.com |\n| 2 | bob@example.com |\n| 3 | john@example.com |\n+----+------------------+\nOutput: \n+----+------------------+\n| id | email |\n+----+------------------+\n| 1 | john@example.com |\n| 2 | bob@example.com |\n+----+------------------+\nExplanation: john@example.com is repeated two times. We keep the row with the smallest Id = 1.\n\n", "translatedTitle": null, "translatedContent": null, "isPaidOnly": false, "difficulty": "Easy", "likes": 90, "dislikes": 21, "isLiked": null, "similarQuestions": "[]", "exampleTestcases": "{\"headers\": {\"Person\": [\"id\", \"email\"]}, \"rows\": {\"Person\": [[1, \"john@example.com\"], [2, \"bob@example.com\"], [3, \"john@example.com\"]]}}", "categoryTitle": "Database", "contributors": [], "topicTags": [ { "name": "Database", "slug": "database", "translatedName": null, "__typename": "TopicTagNode" } ], "companyTagStats": null, "codeSnippets": [ { "lang": "MySQL", "langSlug": "mysql", "code": "# Please write a DELETE statement and DO NOT write a SELECT statement.\n# Write your MySQL query statement below\n", "__typename": "CodeSnippetNode" }, { "lang": "MS SQL Server", "langSlug": "mssql", "code": "/* \n Please write a DELETE statement and DO NOT write a SELECT statement.\n Write your T-SQL query statement below\n */\n", "__typename": "CodeSnippetNode" }, { "lang": "Oracle", "langSlug": "oraclesql", "code": "/*\n Please write a DELETE statement and DO NOT write a SELECT statement.\n Write your PL/SQL query statement below\n */\n", "__typename": "CodeSnippetNode" } ], "stats": "{\"totalAccepted\": \"215.2K\", \"totalSubmission\": \"412.3K\", \"totalAcceptedRaw\": 215167, \"totalSubmissionRaw\": 412328, \"acRate\": \"52.2%\"}", "hints": [], "solution": { "id": "210", "canSeeDetail": true, "paidOnly": false, "hasVideoSolution": false, "paidOnlyVideo": true, "__typename": "ArticleNode" }, "status": null, "sampleTestCase": "{\"headers\": {\"Person\": [\"id\", \"email\"]}, \"rows\": {\"Person\": [[1, \"john@example.com\"], [2, \"bob@example.com\"], [3, \"john@example.com\"]]}}", "metaData": "{\n \"mysql\": [\n \"Create table If Not Exists Person (Id int, Email varchar(255))\"\n ],\n \"mssql\": [\n \"Create table Person (Id int, Email varchar(255))\"\n ],\n \"oraclesql\": [\n \"Create table Person (Id int, Email varchar(255))\"\n ],\n \"database\": true,\n \"manual\": true\n}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [ "Create table If Not Exists Person (Id int, Email varchar(255))", "Truncate table Person", "insert into Person (id, email) values ('1', 'john@example.com')", "insert into Person (id, email) values ('2', 'bob@example.com')", "insert into Person (id, email) values ('3', 'john@example.com')" ], "enableRunCode": true, "enableTestMode": false, "enableDebugger": false, "envInfo": "{\"mysql\": [\"MySQL\", \"
MySQL 8.0
.
mssql server 2019
.
Oracle Sql 11.2
.