I want to create an SQL query where I check if duplicates exist in several different tables. I do this in Teradata. I want the output to look like the following.
|Table A| |Table B| |Table C| |Table D| |Table D|
For each of these columns we can get the value Y
or N
.
(Y means that duplicates exist, N means that duplicates does not exist).
How do I create this script I have managed to write the code for how to check for duplicates in a a table:
SELECT Customer_Id, Year_Month_Id, count(*)
FROM A
GROUP BY 1,2
HAVING count(*)>1)