I have an Employee table with these columns :
- EmployeeId
- Fullname
- Phone
- Department
- Team
- Function
- Manager
and EmployeeHistory containing the history with different columns, but there are some in common :
- EmployeeId
- Fullname
- Geolocation
- Department
- Team
- Function
- Manager
How can I union them?
Advertisement
Answer
Replace uncommon columns by dummy values.
SELECT EmployeeId , Fullname , 'Undefined' AS Email, Phone , 'Undefined' AS Geolocation Department , Team , [Function] , Manager FROM Employee UNION ALL EmployeeId , Fullname , Email , '0000000000' AS Phone, Geolocation, Department , Team , [Function] , Manager FROM EmployeeHistory