MSSQL: simple solution via full outer join
Hi, there! \nTo solve this problem, you need to take the following steps:\n1.  Simply join the two tables (sets) with a full outer join;\n2.  Add tuple filterin
Hi, there! \nTo solve this problem, you need to take the following steps:\n1.  Simply join the two tables (sets) with a [*full outer join*](https://www.w3schools.com/sql/sql_join_full.asp);\n2.  Add tuple filtering condition to where:\n```1 = 1``` used to make it easier to remove conditions through a "--" comment\n```and E.[name] is null``` because we need employees without names\n```or S.[salary] is null``` ...or without salaries;\n3. Now we need to display the ID of the employee who has *null* in one of the tables (*Employees* OR *Salaries*). To do this, we use *[coalesce](https://docs.microsoft.com/en-us/sql/t-sql/language-elements/coalesce-transact-sql?view=sql-server-ver15)*. In short, function ```coalesce(E.[employee_id], S.[employee_id])``` in this case substitutes the value of the second argument if the first argument is NULL.\n4. Finally, we just sort the *coalesce* function result, because by description, we must return the result in ascending order.\n\n```\nselect\n    coalesce(E.[employee_id], S.[employee_id]) as \'employee_id\'\nfrom [dbo].[Employees] E\n    full outer join [dbo].[Salaries] S\n        on E.[employee_id] = S.[employee_id]\nwhere 1 = 1\n    and E.[name] is null\n    or S.[salary] is null\norder by \'employee_id\';\n```
['MS SQL Server']