There are 2 tables, Employee and Department. There are few records in employee table, for which, the department is not assigned. The output of the query should contain all th employees names and their corresponding departments, if the department is assigned otherwise employee names and null value in the place department name. What is the query?
RE: There are 2 tables, Employee and Department. There...
Hi All
A bit lengthy but a good alternative for the JOINS...
(Select E.Emp_Name as EmployeeName D.Dept_Name as DepartmentName D.Dept_Id as DepartmentID from #tmp_Emp E #tmp_Dept D where E.Dept_Id D.Dept_Id ) UNION (Select E.Emp_Name as EmployeeName DepartmentName 'NULL' E.Dept_Id as DepartmentID from #tmp_Emp E where E.Dept_Id IS NULL )