本文介绍了使用COUNT函数跨多个列进行匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构造一个Oracle SQL查询,以便在两列中的表中查找匹配的数据.

我有一张大桌子,上面有以下各列(除其他外):
"ModuleItemID" [主键int]
匹配模块名称查找表的"ModuleNumber" [int]列
"PartNo"列[string]

单个ModuleNumber可以与多个PartNo关联,但是每个PartNo只能与每个ModuleNumber一起出现一次.

我需要根除以相同ModuleNumber出现两次的PartNos的多个实例-即使用计数大于1的特定ModuleNumber和PartNo组合查找所有ModuleItemID行"-但我不确定确切的语法是什么.

在下面的示例中,我想查找重复的行,例如1& 3和7& 9:

ModuleItemID ModuleNumber PartNo
1 1 161-4514
2 1 168-0056
3 1 161-4514
4 2 160-4514
5 2 168-0056
6 3 160-4514
7 3 171-0023
8 3 181-0565
9 3 171-0023


谢谢!

I''m trying to construct an Oracle SQL query to find matching data in a table across two columns.

I have a large table with the following columns (among others):
''ModuleItemID'' [Primary Key int]
''ModuleNumber'' [int] column matching to a lookup table of Module Names
''PartNo'' column [string]

A single ModuleNumber can be associated with many PartNo''s, but each PartNo should only appear with each ModuleNumber once.

I need to root out several instances of PartNos that appear twice with the same ModuleNumber - i.e. "find all ModuleItemID rows with a particular ModuleNumber and PartNo combination where count >1" - but I''m not sure what the exact syntax is.

In the example below, I want to find duplicate rows like 1 & 3 and 7 & 9:

ModuleItemIDModuleNumberPartNo
11161-4514
21168-0056
31161-4514
42160-4514
52168-0056
63160-4514
73171-0023
83181-0565
93171-0023


Thank you!

推荐答案


这篇关于使用COUNT函数跨多个列进行匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 00:25