sql如何查询重复值并给其中一个重复值后增加值?

如题所述

可使用如下语句,其中col 为重复值的字段名

select * from t where col in(select col from t as t2 group by col having count(*) > 1);

select T.* from T join (select col from T group by col having count(*) > 1) as T2
on T.col= T2.col
温馨提示:答案为网友推荐,仅供参考
第1个回答  2019-10-30
sql server环境下,供参考:
select A列,iif(RowNum=0,B列,B列+cast(RowNum as varchar(10))) B列 from
(select A列,B列,row_number() over(partition by B列 order by A列)-1 RowNum from table_A) a本回答被提问者和网友采纳
相似回答