id city_id y_id nam icon
44198 1391 131 loong 9
44198 1391 131 loong 14
上述表数据,想要根据id去除重复记录,最终结果
44198 1391 131 loong 9
或者
44198 1391 131 loong 14都可以。
请各位大侠帮忙。
------解决方案--------------------
with t1 as
(
select 44198 id,1391 city_id,131 y_id,'loong' nam,9 icon from dual
union all
select 44198 id,1391 city_id,131 y_id,'loong' nam,14 icon from dual
union all
select 44444 id,1111 city_id,222 y_id,'loong' nam,4 icon from dual
union all
select 44444 id,1111 city_id,222 y_id,'loong' nam,1 icon from dual
)
select id,city_id,y_id,nam,icon
from
(
select t1.*,row_number() over(partition by id order by rownum) rn
from t1
)
where rn = 1
id city_id y_id nam icon
--------------------------------------------------
1 44198 1391 131 loong 9
2 44444 1111 222 loong 4