重复记录保留一条的初级问题
表t1,字段F1,F2,F3,F4
F1,F2,F3,F4均匀重复
我想查询出一个F1不重复,其他任意的记录集
select *, count(distinct F1) from t1 group by F1
不行
[解决办法]
这样可以吧?
create table t1 (f1 number(10),f2 number(10),f3 number(10),f4 number(10));insert into t1 values (1,10,20,30);insert into t1 values (1,5,2,4);insert into t1 values (1,2,4,3);insert into t1 values (2,10,20,30);insert into t1 values (2,5,1,8);insert into t1 values (3,5,55,5);insert into t1 values (4,6,6,6);insert into t1 values (4,33,36,33);insert into t1 values (5,6,6,6);insert into t1 values (5,88,88,88);select f1,f2,f3,f4 from (select f1,f2,f3,f4,row_number() over(partition by f1 order by f1) rnfrom t1)where rn=1 f1 f2 f3 f4 ---------------------------------------1 1 10 20 302 2 10 20 303 3 5 55 54 4 6 6 65 5 6 6 6