Combine 3 Lists

jonealmass

New Member
Joined
Apr 25, 2017
Messages
7
I have 3 tables of employees.
1. Employees who started the company
2. Employees who were recruited
3. Employees that were reinstated

I want to create one list of employees. Employees can be on as many as 2 lists. I only want that employee listed once. How do I do that.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Combine the list of employees to one sheet and run a "Remove duplicates" using the built in functions on the Data Tab of the Ribbon.
 
Upvote 0
Combine the list of employees to one sheet and run a "Remove duplicates" using the built in functions on the Data Tab of the Ribbon.
This is posted in the Access part of the forum, so I think that they are looking for an Access solution instead of an Excel one.

In Access, I would create a Union Query (see: https://support.office.com/en-us/ar...e-result-1f772ec0-cc73-474d-ab10-ad0a75541c6e)

So the code for that would be structured something like this:
Code:
SELECT Table1.Employee 
FROM Table1
UNION
SELECT Table2.Employee
FROM Table2
UNION
SELECT Table3.Employee
FROM Table3;
 
Last edited:
Upvote 0
Ok. What if the tables all location as well. So I want the employee number and location. A person could have started at one location and got reinstated at another. How do I do that? I only want the original location.
 
Upvote 0
Hi,
apart or before writing the SQL query itself, how would you identify which is an original location as compared to one that is not original? Do you have dates or any other identifying information? This will affect how you write the query.
 
Upvote 0
I only want the original location.
How can you determine that from the data?
Is there a date associated with these fields?
Perhaps some data examples would be in order here.
 
Upvote 0
Yes. I can create a date field. So the fields would be:
Employee
Location
Date

Thanks for all your help!
 
Upvote 0
Since hirestatus will be different in each table, you will not avoid duplicates anymore. You might have to go with some subqueries at this point... first you will want to find the minimum date for each employee, then backtrack to the location that goes with that date.

A possible solution therefore:
Code:
select 	
	A.Employee, A.[date]
from
	(
		select employee, location, [date] from table1
		union all
		select employee, location, [date] from table2
		union all
		select employee, location, [date] from table3

	) as A
inner join
	(
		select B.employee, min(B.[date]) as MinOfDate
		from
			(
			select employee, [date] from table1
			union all
			select employee, [date] from table2
			union all
			select employee, [date] from table3
			) as B
		group by B.employee
	) as C
on 
	A.employee = C.employee
	and A.[date] = c.MinOfDate
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,795
Members
449,468
Latest member
AGreen17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top