eugz
October 6, 2020, 6:29pm
1
Hi All.
When I join this two tables
SELECT
Name,
Description,
EmployeeDeptId,
FROM EmployeeDept ed
JOIN Department d
ON ed.DepartmentId = d.DepartmentId
as in result I'm getting duplicates for Name . How to join tables and eliminate duplicates?
Thanks.
mike01
October 6, 2020, 7:23pm
2
The employee belongs to more than 1 department. Pictures are nice, but DDL and sample data would be better. I see IsActive, should that be used? If an employee is assigned to more than one department, which it sounds like your data has, then you will get multiple rows.
Or there are many employees in same department and since you have no filter there will be duplicate department Name
Mateen
October 7, 2020, 5:55pm
4
What is the row count of this query
select [name] from department
and what is the row count of this query
select distinct [name] from department
I dont think that makes a difference, look at the query. If you and I are in same department of course there will be 2 of the same department right?
Mateen
October 7, 2020, 6:26pm
6
Yes, several people can belong to same department.
Since he did't provide his duplicate result set,
I thought second possibility of asking his question.