You are on page 1of 1

1.

2.
3.
4.
5.
6.
7.

What's the difference between an inner and an outer join?


What's the difference between where and having?
What's the difference between a primary key and a unique key?
How would you select the first 100 records of a select that you expected more than 100?
What's the difference between delete and truncate?
How would you do a where clause that checks for a null value?
Can you tell me the difference between union and union all?

Let's stay that we have a table with Employee name, gender and salary.
8. How would you create a SQL Query to find second highest salary of any Employee?
Answer : There are many ways to find second highest salary of Employee in SQL, you can
either use SQL Join or Subquery to solve this problem. Here is SQL query using Subquery :
select MAX(Salary) from Employee WHERE Salary NOT IN (select MAX(Salary) from
Employee );
9. How would you create a SQL Query find number of employees according to gender whose
DOB is between 01/01/1960 to 31/12/1975.
Answer: SELECT COUNT(*), gender from Employees WHERE DOB BETWEEN '01/01/1960'
AND '31/12/1975' GROUP BY gender;
10.How would you write an SQL Query to find name of employee whose name Start with M
Answer: SELECT * FROM Employees WHERE EmpName like 'M%';
11.Let's say that you have a large table and that you want to copy the data from one
database to another, how would you do that?
12.What are the largest databases that you have worked with?
13.Let's say that you have a large table and when you do a select from it it's taking too long,
what steps might you take to improve performance?
14.Let's say that you had table A and table B and they have a simple relationship, how would
you select all of the records from table A where there is NOT a match in table B?
15.How could a sub query cause a performance problem?

You might also like