How can I delete duplicate rows in SQL. Here is the current query. Select EmployeeID, Username,
How can I delete duplicate rows in SQL. Here is the current query.
Select
EmployeeID,
Username,
FirstName,
LastName,
RoleName,
RoleDescription,
Count(*) as '# of Duplicates'
From
[dbo].[vw_MyAccessInfo]
Group by EmployeeID, Username, FirstName, LastName, RoleName,RoleDescription
Having Count(*) > 1
Delete from [dbo].[vw_MyAccessInfo]
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
This query is not correct as I'm still receiving this error.
Msg 4145, Level 15, State 1, Line 15
An expression of non-boolean type specified in a context where a condition is expected, near ','.
Msg 102, Level 15, State 1, Line 17
Incorrect syntax near ')'.
Here is the query provided by you.
The query provided is giving me errors (see below). Can you assist?
Msg 4104, Level 16, State 1, Line 5
The multi-part identifier "x2.id" could not be bound.
Completion time: 2022-08-09T11:32:00.7475729-05:00
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)