Tuesday, April 6, 2010

DataBase Testing Interview Questions

Database testing is one of the important testing technique to see whether what is happening on the UI is actually being done in the backendi n database. Whether the records are inserted or updated etc, a database integrity check should be done and that is the reason Database Testing is given importance.

Below are some of the interview questions on Database Testing with answers. Hope these migt be helpful.

1. Write a query to find the second largest value in a given column of a table?


Select MAX(Salary) from EmployeeDetails
where Salary < (select MAX(Salary)from EmployeeDetails);


First this statement in the where condition "select MAX(Salary)from EmployeeDetails" is executed which gives the maximum salary of the table. This is the highest max salary. Then the statement before the where condition is executed and is stored as salary. This value is compared with the max salary to satisfy the less than condition and gives the second highest salary.


2. Write a query to find the person with "nth" highest salary?


Select * from EmployeeDetails a where 15 = (select count(distinct(Salary)) from EmployeeDetails b where a.Salary <=b.Salary);

No comments:

Post a Comment