I'm trying to locate duplicate data in a table using 4 columns:
employee_id (primary key), employeeid, lastname and firstname.
I can pull up the duplicate data with the last three listed columns,
but when I include the first column (employee_id) in the statement, it
shows nothing, since the employee_id value is unique for each row.
Here's the statement I'm currently using:
select employeeid, firstname, lastname
from empmain
group by employeeid, firstname, lastname
having count(*) 1
The only thing I need extra from this statement is a separate row for
each duplicate value, showing the unique employee_id value. I know I
need to take the Group By option out, but I get the error "Column
'empmain.employ eeid' is invalid in the select list because it is not
contained in either an aggregate function or the GROUP BY clause.".
Tried doing research on this issue, but honestly, my knowledge of SQL
is limited and I'm really not sure I'm asking the right questions when
searching. Any help would be appreciated.
- Travis
employee_id (primary key), employeeid, lastname and firstname.
I can pull up the duplicate data with the last three listed columns,
but when I include the first column (employee_id) in the statement, it
shows nothing, since the employee_id value is unique for each row.
Here's the statement I'm currently using:
select employeeid, firstname, lastname
from empmain
group by employeeid, firstname, lastname
having count(*) 1
The only thing I need extra from this statement is a separate row for
each duplicate value, showing the unique employee_id value. I know I
need to take the Group By option out, but I get the error "Column
'empmain.employ eeid' is invalid in the select list because it is not
contained in either an aggregate function or the GROUP BY clause.".
Tried doing research on this issue, but honestly, my knowledge of SQL
is limited and I'm really not sure I'm asking the right questions when
searching. Any help would be appreciated.
- Travis
Comment