您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

ORACLE Select Distinct返回许多列,其中

ORACLE Select Distinct返回许多列,其中

据我了解,此查询应该可以解决您的问题:

select distinct a.* from temp_ids a join

(select name, max(col1 || ' ' || col2  || ' ' || col3) id
from temp_ids
where col1 = 2
group by name
) b

on (a.name = b.name and (col1 || ' ' || col2  || ' ' || col3) = b.id)
;

当然,最好使用唯一记录ID代替串联,但是可以生成ID。确保id的函数为每个列组合返回唯一值(在这种情况下使用(col1 ||’‘|| col2 ||’‘||col3))

Oracle 2022/1/1 18:50:31 有382人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶