1、创建测试表,
create table test_dis(id number, name varchar2(20), value number(10))
2、插入测试数据
insert into test_dis values(1,'a',123)
insert into test_dis values(2,'b',152)
insert into test_dis values(3,'c',123)
insert into test_dis values(4,'d',520)
insert into test_dis values(5,'e',300)
commit
3、查询表中全量数据,select t.*, rowid from test_dis t
4、编写sql,查询表中某一字段不重复的所有数据,可以发现只有id为2,4,5的记录查询出。
select * from test_dis t where value in (select value from test_dis group by value having count(*)=1)
比如:cc列如下:
xxx
vvv
bbbb
ccc
xxx
想只要显示
xxx
vvv
bbbb
ccc
解决方法如下:
如果得到所有值不重复。
select cc from tablename group by cc
或
select distinct cc form tablename
如果得到没有重复的所有制,
select cc from tablename group by cc
minus
select cc
from(
select cc,count(*) from tablename group by cc having count(*)>1) A
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)