oracle查询语句过滤重复数据问题

oracle查询语句过滤重复数据问题,如下:字段名为x和y,表名为t
x y
a b
a c
a d
a b
a c
a d
请问如何查询能得到以下结果:
x y
a b
a c
a d
先谢过了

select distinct x,y ferom t;
select x,y from t group by x,y;
select * from t group by x,y having count(*)>1 ;--查出有重复记录的数据,如果having count(*)=1 是查出没有重复记录的数据
select * from t a1 where rowid=(select max(rowid) from t a2 where a2.x=a1.x and a2.y=a1.y); --利用rowid唯一,适用于少量重复数据
还有 rank over(partition)这个函数你也可以好好看哈哦
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-11-22
select distinct x, y from t;
第2个回答  推荐于2017-09-04
第一种方式:
select distinct x, y from t;

第二种方式:
select x,y from t group by x,y

推荐第二种方式本回答被提问者和网友采纳
第3个回答  2012-11-22
select distinct x, y from t;
或者
select x,y from (select x,y,count(*) from t group by x,y) b;
第4个回答  2012-11-22
select temp.x, temp.yfrom (
select t.x, t.y, row_number() OVER(PARTITION BY x ORDER BY t.y desc) as row_flg from t t ) tempwhere temp.row_flg = '1'