Two MS SQL solution
Two solutions for MS SQL Server.\n\nThe first one seems quite long but it\'s more like a step-by-step approach, easy to follow and understand.\n\nWe create a ta
Two solutions for MS SQL Server.\n\nThe first one seems quite long but it\'s more like a step-by-step approach, easy to follow and understand.\n\nWe create a table based on Employees, join it with Salaries on \'employee_id\' from both. The question here is: what ids do we have in the first table that are not present in the second table? We do the same in reverse for Salaries and finally Union the two tables.\n\n```\nSELECT \n    e.employee_id\nFROM \n    Employees AS e\nLEFT JOIN\n    Salaries AS s\n        ON e.employee_id = s.employee_id\nWHERE s.employee_id IS NULL\n\nUNION\n\nSELECT \n    s.employee_id\nFROM \n    Salaries AS s\nLEFT JOIN\n    Employees AS e\n        ON s.employee_id = e.employee_id\nWHERE e.employee_id IS NULL\nORDER BY e.employee_id\n```\n\nOr we can achieve the same with COALESCE in more elegant way. COALESCE returns the first NOT NULL value.\n\n```\nSELECT\n    COALESCE(e.employee_id, s.employee_id) AS employee_id\nFROM \n    Employees AS e\nFULL JOIN\n    Salaries AS s\n        ON e.employee_id = s.employee_id\nWHERE\n    e.name IS NULL OR s.salary IS NULL\nORDER BY employee_id\n```
['MS SQL Server']