0 Star 0 Fork 231

rockylee/python-learn

forked from mktime/python-learn 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
repeated.sql 1.16 KB
一键复制 编辑 原始数据 按行查看 历史
mktime 提交于 2014-02-28 18:49 . 删除重复记录的一种方法
CREATE TABLE tf_user(
ID NUMBER(14),
NAME VARCHAR2(255),
email VARCHAR2(255)
);
Insert into TF_USER
(ID, NAME, EMAIL)
Values
(1, 'chengwei', 'chengwei@tencent.com.cn');
Insert into TF_USER
(ID, NAME, EMAIL)
Values
(2, 'lizm', 'lizm@tencent.com.cn');
Insert into TF_USER
(ID, NAME, EMAIL)
Values
(3, 'changhj', 'changhj@tencent.com.cn');
Insert into TF_USER
(ID, NAME, EMAIL)
Values
(4, 'wujun', 'wujun@tencent.com.cn');
Insert into TF_USER
(ID, NAME, EMAIL)
Values
(5, 'mmtye', 'mmtye@tencent.com.cn');
Insert into TF_USER
(ID, NAME, EMAIL)
Values
(6, 'guona', 'guona@tencent.com.cn');
Insert into TF_USER
(ID, NAME, EMAIL)
Values
(7, 'chengwei', 'chengwei@tencent.com.cn');
Insert into TF_USER
(ID, NAME, EMAIL)
Values
(8, 'guona', 'guona@tencent.com.cn');
Insert into TF_USER
(ID, NAME, EMAIL)
Values
(9, 'mmtye', 'mmtye@tencent.com.cn');
Insert into TF_USER
(ID, NAME, EMAIL)
Values
(10, 'chengwei', 'chengwei@tencent.com.cn');
-- 一条语句删除name重复的记录
DELETE FROM tf_user WHERE ROWID NOT IN(
SELECT b.rod from (
SELECT MIN(ROWID) rod, NAME FROM tf_user a
GROUP BY NAME) b);
SELECT * from tf_user;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/isliwg/python-learn.git
git@gitee.com:isliwg/python-learn.git
isliwg
python-learn
python-learn
master

搜索帮助