Say I have a table that has three columns,
dateReg, email, age.
I want to find duplicates and display all the columns. If I do this it shows duplicate emails, just showing that column:
But if I say
and the rest of the code below this line is the same, it gives me an error
Msg 8120, Level 16, State 1, Line 1
Column dateReg' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
How do I display duplicates, but with all columns of the duplicate entry showing?
dateReg, email, age.
I want to find duplicates and display all the columns. If I do this it shows duplicate emails, just showing that column:
Code:
SELECT email,
COUNT(email) AS NumOccurrences
FROM users
GROUP BY email
HAVING ( COUNT(email) > 1 )
But if I say
Code:
Select email, dateReg,
...
Msg 8120, Level 16, State 1, Line 1
Column dateReg' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
How do I display duplicates, but with all columns of the duplicate entry showing?
