Oracle:行转列函数,查询重复记录函数,过滤表中重复记录函数

1 行转列函数:
select wm_concat(username) from users

2 查询重复记录函数
select t.* from(select t.*,rownum rn from USERS  t where t.username in (select username from USERS group by username having count(*) > 1))  t

3 过滤表中重复记录函数
有一张User表,姓名字段重复
A
select t.* from(select t.*,rownum rn from USERS  t where t.username not in (select username from USERS group by username having count(*) > 1))t
union all
select t.* from(select t.*,rownum rn from USERS  t where t.username in (select username from USERS group by username having count(*) > 1))  t where t.rn=1

B
select * from (select t. *,row_number() over(partition by username order by username) rn from USERS t) tt where tt.rn=1;


其它参考资料
oracle中的exists 和not exists 用法
http://javannp.iteye.com/blog/486200

你可能感兴趣的:(oracle,sql,Blog,ITeye)