数据:
id type flag
01 send a
01 send b
01 send c
02 send a
02 send b
01 rece a
01 rece b
结果为:
01 send a
02 send a
id和flag是联合主键,要删除id重复的数据,结果如上,sql语句怎么写,并解释一下好吗
id type flag
01 send a
01 send b
01 send c
02 send a
02 send b
01 rece a
01 rece b
结果为:
01 send a
02 send a
id和flag是联合主键,要删除id重复的数据,结果如上,sql语句怎么写,并解释一下好吗
---------- -------------------- ----
01 send a
01 send b
01 send c
02 send a
02 send b
01 race a
01 race b7 rows selectedSQL>
SQL> select id,type,flag from (
2 select id,type,flag,row_number() over(partition by id order by id) rm from t2) a where rm=1;ID TYPE FLAG
---------- -------------------- ----
01 send a
02 send a
where row_id<
(
select max(rowid) from tablename b
where a.id=b.id
)
方法很多,可以参考这个技术博客
select id,type,flag,row_number() over(partition by id order by id) rm from t2) a where rm=1;1楼的partition by id是什么意思, over(partition by id order by id) rm from t2) a 又是什么意思,请指教
还有5楼的sql语句是什么意思