I have to find, if there is any row in the table for which value of col2 is duplicate. Like in the specified scenario row 1 and 2 are duplicate as value of col2 is same.
Table
-------------------
Col1 Col2 Col3
1 1 4
2 1 3
3 2 2
4 3 1
At present what i am doing is
select count(*) from table group by col2 order by 1 desc
if the value of first row is > 1 then there are duplicates.
Please specify any optimized query for this problem.
Note The table contains trillions of data, and there is no index on col2 [ if that matters to you ]