Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Selecting duplicate records from a table - Complete record and not just the duplicate keys - response (3) by dnoeth

$
0
0

You're correct, there should be at least twice the number of rows returned. Your code is overly complex, you don't need the DISTINCT and the Derived Table A, but this will not change the result:

SELECT A.*
FROM TABLE A
INNER JOIN
 (
   SELECT COL1,COL2,COL3
   FROM TABLE
   GROUP BY COL1,COL2,COL3
   HAVING COUNT(*)>1
 ) B
ON
A.COL1=B.COL1 AND
A.COL2=B.COL2 AND
A.COL3=B.COL3

 
There must be something else, could you post your actual query?
 
Depending on the number of columns in your table and the number of duplicates there is another approach:

SELECT *
FROM TABLE
QULAIFY
  COUNT(*) OVER (PARTITION BY COL1,COL2,COL3) > 1

 
Dieter


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>