如何为以下问题编写SQL?

Rak*_*yal 0 sql db2

我必须找到,如果表中有任何行col2的值是重复的.与在指定的场景中一样,第1行和第2行是重复的,因为col2的值是相同的.

Table
-------------------
Col1   Col2  Col3
1       1     4
2       1     3
3       2     2
4       3     1
Run Code Online (Sandbox Code Playgroud)

目前我在做的是

select count(*) from table group by col2 order by 1 desc
Run Code Online (Sandbox Code Playgroud)

如果第一行的值> 1则存在重复.

请为此问题指定任何优化查询.

注意 该表包含数万亿的数据,并且col2上没有索引[如果这对您很重要]

dav*_*vek 5

select * from MyTable where col2 in
(
select col2
from MyTable
group by col2
having count(*) > 1
) x
Run Code Online (Sandbox Code Playgroud)