Remove the duplicate rows from the table having a foreign key from another table?

advertisements

I am having two tables employee and departments. employee table having

ID , name ,  salary, dep_ID
1  | john |  2300  | 1
2  | smith|  1500  | 2
3  | john |  2300  | 1

here the dep_id is a foreign key

now department

id, name
1 | COMPUTER SCIENCE
2 | MATHEMATICS

Now what I want to do is "delete all the duplicate row from the employee table "


delete  from Employee
where   id not in
        (
        select  minid
        from    (
                select  min(id) as minid
                from    Employee
                group by
                        name
                ,       salary
                ,       dep_ID
                ) sub
        )

Example at rextester.com.