SQL Practice Questions - 2
SQL Practice Questions - 2
Using HR.EMPLOYEES, HR.DEPARTMENTS and HR.JOBS tables in Oracle Live SQL environment, write
SQL queries to answer below questions.
1. Fetch Employee Name, Manager Name and Department Name for all employees.
2. Write an SQL to fetch immediate previous job details of each employee. Required columns
are Employee Id and previous job details (whatever data is available about previous jobs).
3. Write an SQL to fetch below columns.
Department Name, Manager Name, Minimum Salary of Employee under the Manager,
Maximum Salary of Employee under the Manager.
4. Fetch highest salaries against each department. Output Columns: Department Name,
Maximum salary.
5. Order each employee as per their salary among their corresponding department. Output
columns: Department Name, Employee Name, Salary, Position of Employee as per
salary(ex: 1 = Highest salary, 2 = 2nd highest salary so on)
6. Which Manager has the biggest team in the company?
7. Are there any Managers who are reporting to other managers? If so, how many such
managers are there?
8. Write a sql query to fetch below result.
Output columns: Department Name, Join Date, Cost to Company (sum of salaries
company has to pay to all the employees hired until the joining date).
9. Which Employee has the highest commission. (Actual value not the %)
10. Write a SQL query to fetch department wise difference between the employee salary and
his/her next highest salaried employee. Output columns: Department Name, Employee
Name, Salary, Salary Difference.