Saturday, May 14, 2011

.NET and SQL Server interview questions - Which query is used to merge two different columns into single column?


Answer:

let's us assume that we have the following table of Employee.





Now we want to merge the Emp_Salary_2010 and Emp_Salary_2011 columns into a
single column as Salary.

Query:-

select Emp_Name,Emp_Salary_2010 as Salary from Employee
union
select Emp_Name,Emp_Salary_2011 as Salary from Employee

Output:-




Please click here to see more .NET and SQL Server interview questions

Regards,

Visit Authors blog for more .NET and SQL Server interview questions

No comments: