Remove Duplicates from Table

来源:互联网 发布:python win服务器 编辑:程序博客网 时间:2024/06/08 01:02

Remove Duplicates from Table

[Description]
You are give a table named Person

Code:  Select all
[Description]You are give a table named PersonCode: Select all+-------------+---------+| Column Name | Type    |+-------------+---------+| email       | varchar || id          | int     |+-------------+---------+id is the primary key column for this table.Write a SQL to delete all the duplicated email records

id is the primary key column for this table.

Write a SQL to delete all the duplicated email records

For example, if the rows are:

For example, if the rows are:+----+-------------+| 1  | a@gmail.com || 2  | b@gmail.com || 3  | a@gmail.com || 4  | b@gmail.com |+----+-------------+Does deleting duplicate email records mean deleting all duplicates except the first entry?+----+-------------+| 1  | a@gmail.com || 2  | b@gmail.com |+----+-------------+Or we don't care if the deleted entry is not the first one, such as this is correct too?+----+-------------+| 3  | a@gmail.com || 4  | b@gmail.com |+----+-------------+



0 0
原创粉丝点击