oracle中去掉某列重复的记录
来源:互联网 发布:linux查看物理cpu个数 编辑:程序博客网 时间:2024/05/16 01:23
1.准备测试表
创建测试表
create table temp_mul_tbl( id varchar2(20) primary key, name varchar2(50), age int);
为表和字段添加注释
comment on table temp_mul_tbl is '测试表';comment on column temp_mul_tbl.id is '主键';comment on column temp_mul_tbl.name is '姓名';comment on column temp_mul_tbl.age is '年龄';
创建该表主键要用的序列
comment on table temp_mul_tbl is '测试表';comment on column temp_mul_tbl.id is '主键';comment on column temp_mul_tbl.name is '姓名';comment on column temp_mul_tbl.age is '年龄';
添加测试数据
insert into temp_mul_tbl(id, name, age)values(seq_temp_mul_tbl.nextval, 'lxl', 26);insert into temp_mul_tbl(id, name, age)values(seq_temp_mul_tbl.nextval, 'zhangsan', 26);insert into temp_mul_tbl(id, name, age)values(seq_temp_mul_tbl.nextval, 'lxl', 27);insert into temp_mul_tbl(id, name, age)values(seq_temp_mul_tbl.nextval, 'lisi', 28);insert into temp_mul_tbl(id, name, age)values(seq_temp_mul_tbl.nextval, 'wangwu', 28);insert into temp_mul_tbl(id, name, age)values(seq_temp_mul_tbl.nextval, 'lxl', 23);insert into temp_mul_tbl(id, name, age)values(seq_temp_mul_tbl.nextval, 'lxl', 24);
2.进行测试
执行以下sql,查询出所有的记录
seq_temp_mul_tbl结果如下图所示
下面我们要去掉name重复的记录,sql如下:
select * from temp_mul_tbl t where t.id in (select max(s.id) from temp_mul_tbl s where s.name = t.name);
执行结果如下:
和上面查询全部的结果相比较,已经去掉了name重复的记录, name 为 “lxl” 的记录,只显示了一条。
0 0
- oracle中去掉某列重复的记录
- wps去掉列的重复记录
- Oracle根据某列去掉重复行
- 去掉list中重复的记录
- 去掉dt中重复记录
- 怎样去掉重复的记录
- 查询某列重复的记录
- Oracle查询重复记录,分页和去掉重复数据的查询语句
- Oracle查询重复记录,分页和去掉重复数据的查询语句
- Oracle中删除重复的记录
- oracle中删除重复的记录
- Oracle存储过程中去掉重复字符串的函数
- 删除列重复的记录
- 数据库查询 去掉 某列重复数据
- 去掉重复记录和查询重复记录的常见方法
- 去掉表里组合字段重复的记录
- 查询时去掉重复记录的问题
- SQL语句去掉重复的记录
- Java中线程小结
- ZOJ-2370
- 2014年4月23日
- Big O,Big Theta,Big Omega,little o,little omega notation的定义
- Web 前端性能优化——使用索引对象
- oracle中去掉某列重复的记录
- 不通过表单访问带有命名空间的action
- IIS配置遇到的问题—— 处理程序“PageHandlerFactory-Integrated”在其模块列表中有一个错误模块“ManagedPipelineHan
- 双缓冲消息队列-减少锁竞争
- 多线程
- Android 双色球机选算法
- 正则表达式30分钟入门教程
- 第六周作业——哈夫曼编码
- redis的源码分析之不同编码类型的数据结构