当其中两行需要唯一时选择三行 (SQL)
首先,我使用的是 Oracle 10g Express
所以我想选择三列:
[domain_name] [index_path] [collection_name]
现在有两列我想要唯一:
[domain_name] [index_path]
所以我的问题是我基本上如何:
select unique domain_name, index_path from TABLENAMEHERE
同时选择列 [collection_name]
First of all I am using Oracle 10g Express
So there are three columns I want to select:
[domain_name] [index_path] [collection_name]
Now there are two columns that I want to be unique:
[domain_name] [index_path]
So my issue is how do I basically:
select unique domain_name, index_path from TABLENAMEHERE
while also selecting the column [collection_name]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果domain_name、index_path 的某些组合有多行,那么您希望从这些行中看到collection_name 的什么值?如果您不介意哪个值,请执行以下操作:
If there are multiple rows for some combinations of domain_name, index_path then what value of collection_name would you want to see from those rows? If you don't mind which value then do:
只需在查询中将
unique
替换为distinct
即可。哦...
那应该是这样的:
Just replace
unique
withdistinct
in your query.Oh...
Then it should be like this:
您可以按domain_name 和index_path 进行分组,并在每组中包含一个(最小值或最大值)collection_name 值。
You can group by the domain_name and index_path and include ONE (min or max) value of collection_name per group.