oracle中执行查询语句后,在某几列上,存在多行重复数据的去重方法

sql如下:

select s.* from 
(select row_number() over (partition by t.card_code order by t.id) as group_idx,t.*
from tb_card t where t.name='abc' and t.store_id= 9) s 
where s.group_idx = 1

row_number() over(partition by xxx order by xxx) 其逻辑就是对符合某些特点的字段进行分组,排序,然后再取数据 

 

参考:https://blog.csdn.net/xiangjai/article/details/79658032

你可能感兴趣的:(Oracle,/,Mysql)