60 Questions
60 Questions
database systems and SQL. Here's how I'll structure the levels:
1. Easy: Questions requiring basic SQL operations (e.g., SELECT, COUNT, SUM).
3. Write a query to find all employees hired after the year 2020.
5. Write a query to calculate the total salary of employees with a salary less than
10,000.
10. Write a query to find the last names of employees whose first names start with
"A".
1. Write a query to find the average salary of employees whose salary is greater
than 8,000.
2. Retrieve the names and departments of employees whose salaries are between
10,000 and 20,000.
4. Retrieve the names of employees who have the same salary as the highest-paid
employee in the Sales department.
5. List the departments with fewer than 5 employees.
7. Write a query to list employees with a salary greater than the department average
salary.
8. Find the name and department of the employee with the second-highest salary.
10. Write a query to retrieve employees who share the same last name.
2. Retrieve the names of employees who earn more than the average salary of their
respective departments.
3. Write a query to display departments where the total salary is less than 50,000.
4. Write a query to list employees who have been with the company for more than 5
years.
5. Write a query to calculate the total salary of employees who do not report to any
manager.
7. Write a query to list employees who work in the same department as their
managers.
8. Find the departments with the highest and lowest average salaries.
9. Retrieve all department names along with the total and average salaries in those
departments.
10. Write a query to find employees who have never been assigned to a project.
1. Write a query to retrieve the names of employees who earn more than any
employee in the Sales department.
2. Write a query to find employees whose salary is in the top 10% of the company.
3. Write a query to retrieve employees who do not belong to any department but are
supervised by a manager.
4. Find the employees who have the same job title as the employee earning the
highest salary in the company.
5. Write a query to list departments with total salaries exceeding the company-
wide average salary.
6. Write a query to retrieve employees whose salaries are below the average salary
for their job title.
9. Retrieve the names of employees hired in the same month as the employee with
the maximum salary.
10. Write a query to find all employees who have not received a salary update in the
last two years.
11. Retrieve departments that employ at least one employee earning above 15,000
but have an average salary below 10,000.
12. Write a query to calculate the total salary for each supervisor, considering all
employees they supervise.
13. Retrieve the names of employees who work in departments that employ more
than 5% of the total workforce.
14. Write a query to display departments where the highest-paid employee's salary
is less than 20,000.
15. Retrieve all departments and their total employee counts, including departments
without employees.
16. Write a query to calculate the median salary across all employees in the
company.
17. Find employees who report directly or indirectly to the same manager.
18. Write a query to list employees who were hired before the earliest hire date in the
Sales department.
19. Retrieve the names of employees who are in the top 5% of earners in their
respective departments.
20. Write a query to list employees whose salary is a prime number.
21. Retrieve the names of employees working on the maximum number of projects
within the company.
22. Write a query to find employees whose salary is above the 75th percentile for
their department.
23. Retrieve the total number of employees in each department, including empty
departments, sorted in descending order of the count.
24. Write a query to calculate the standard deviation of salaries in the Engineering
department.
25. Retrieve the names of employees who work in departments where every
employee earns more than 10,000.
26. Write a query to find employees who have the same hire date as their
supervisors.
27. Retrieve all employees who have worked in more than one department during
their tenure.
28. Write a query to identify employees whose total salary exceeds the sum of
salaries in their department (use subqueries).
29. Find the percentage of employees in each department who earn above the
department’s average salary.
30. Write a query to list all employees along with their rank in the company based on
salary (e.g., using RANK() or DENSE_RANK()).