Saturday, May 7, 2011

.NET and SQL Server interview questions :- How your skills are tested with complicated SQL query on SQL CASE syntax?

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

There can be a scenario we have to display employee name whose salary is greater than "some amount" or less than "some amount" for that purpose we use case statement.
Let's us consider that we have to display all the employee names from the employee table and the status like salary is greater than 13000 or lesser than 13000.

 when (Emp_Salary>13000) then 'Greater than 13000'
 else 'Lesser than 13000'
 end as Status
 FROM Employee


Hence you can see that all the employee name have been displayed with their salary status in the above output.
Please click here to see more .NET and SQl Server interview questions

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

No comments: