select * from test1 where rowid in (select rid from (select rowid rid,row_number()over(partition by dm order by rowid) m
from test1) where m =1)
用这个查询test1中dm唯一的,其中order by 后面是排序的字段,保留第一条,
可以理解为 你的结果集中的数据 都是唯一值吗?
select id from t where id not in (select id from t group by id having count(id)>1);
括号中的是id列有重复值的id
你试一下下面这句话。
select 表.*
from 表,
(select 字段
from 表 t
group by 字段
having count(字段) = 1) a
where 表.字段 = a.字段