选择 - 查找重复项 [英] Select - find duplicates

查看:62
本文介绍了选择 - 查找重复项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一些DB2表,其中主键通常是唯一的,但可以重复


我想找到仅重复。

例如,假设主键具有以下值:


21

28

30

30

34

40

52

52


我只想知道30和52左右。

我能用聪明的SQL语句做这个吗?

TIA

Hi
I have some DB2 tables where the primary key is usually unique, but can
be duplicate.
I want to find the duplicates only.
For example, suppose the primary key has these values:

21
28
30
30
34
40
52
52

I want to know about 30 and 52 only.
Can I do this with a clever SQL statement?
TIA

推荐答案



Nananana写道:

Nananana wrote:



我有一些DB2表,其中主键通常是唯一的,但可以重复


我只想找到重复项。

例如,假设主键具有以下值:


21

28

30

30

34

40

52

52


我想知道大约30和52只有。

我能用聪明的SQL语句做这个吗?

TIA
Hi
I have some DB2 tables where the primary key is usually unique, but can
be duplicate.
I want to find the duplicates only.
For example, suppose the primary key has these values:

21
28
30
30
34
40
52
52

I want to know about 30 and 52 only.
Can I do this with a clever SQL statement?
TIA



使用GROUP BY和HAVING COUNT(*)1

Use GROUP BY and HAVING COUNT(*) 1


在2007-01-16 10:37,Nananana写道:
On 2007-01-16 10:37, Nananana wrote:

我有一些DB2表,其中主键通常是唯一的,但可以重复

I have some DB2 tables where the primary key is usually unique, but can
be duplicate.



我不这么认为。主键是唯一的。根据定义。


Benjamin

I don''t think so. Primary keys are unique. By definition.

Benjamin




太棒了 - 谢谢。

我甚至让它工作

:-)

Tonkuma写道:

Great - thanks.
I even got it to work
:-)
Tonkuma wrote:

Nananana写道:
Nananana wrote:



我有一些DB2表,其中主键通常是唯一的,但可以重复
。 br />
我只想找到重复项。

例如,假设主键具有以下值:


21
28

30

30

34

40

52

52


我只想知道30和52左右。

我能用巧妙的SQL语句做到这一点吗?

TIA
Hi
I have some DB2 tables where the primary key is usually unique, but can
be duplicate.
I want to find the duplicates only.
For example, suppose the primary key has these values:

21
28
30
30
34
40
52
52

I want to know about 30 and 52 only.
Can I do this with a clever SQL statement?
TIA



使用GROUP BY和HAVING COUNT(*)1

Use GROUP BY and HAVING COUNT(*) 1

这篇关于选择 - 查找重复项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆