Database interview questions

database, Uncategorised
Question 1: SQL Query to find second highest salary of 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 ); SELECT max(salary) FROM Employee WHERE salary < (SELECT max(salary) FROM Employee); See How to find second highest salary in SQL for more ways to solve this problem. Question 2: SQL Query to find Max Salary from each department. Answer : SELECT DeptID, MAX(Salary) FROM Employee  GROUP BY DeptID. Question 3: Write SQL Query to display current date. Answer: SQL has built in function called GetDate() which returns current timestamp. SELECT GetDate(); Q