• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Need SQL Help

ryan256

Platinum Member
I have a table that I need to find duplicate entries for based on 3 values. If 2 or more rows contain the same values for col_A, col_B, and col_C then they are duplicates.

I was able to do this when the duplicates were determined by a single column using:
SELECT col_A, COUNT(col_A) AS Expr1
FROM Table_1
GROUP BY col_A
HAVING (COUNT(col_A) > 1)
ORDER BY Expr1 DESC

This told me how many duplicates I had of column A. I then used:

SELECT distinct col_A
INTO Table_1_temp
FROM Table_1

This gave me a table free of duplicates.

But I'm lost on how to do this now that there are 3 variables in the mix.
I'm thinking that to get a table free of duplicates based on 3 variables I would use:

SELECT distinct col_A, col_B, col_C
INTO Table_1_temp
FROM Table_1

But again I'm shooting in the dark here as I have very little SQL experience.
 
SQL questions generally belong in the Programming forum, for what it's worth.

Originally posted by: ryan256
I'm thinking that to get a table free of duplicates based on 3 variables I would use:

SELECT distinct col_A, col_B, col_C
INTO Table_1_temp
FROM Table_1

But again I'm shooting in the dark here as I have very little SQL experience.

Yes, from what you've told us, that will give you what you're looking for. If you use SELECT DISTINCT rather than just SELECT, you're essentially telling the server to not return any rows that have identical data to any row that it has already returned.
 
Back
Top