0% found this document useful (0 votes)
2 views

50_SQL_Questions_Master_SQL

The document contains a comprehensive list of 50 SQL questions categorized into four levels: Beginner, Intermediate, Advanced, and Expert. Each section focuses on different SQL concepts such as basic queries, aggregations, joins, subqueries, and optimization techniques. This resource is designed to help individuals master SQL coding through practical exercises.

Uploaded by

ranjankaul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

50_SQL_Questions_Master_SQL

The document contains a comprehensive list of 50 SQL questions categorized into four levels: Beginner, Intermediate, Advanced, and Expert. Each section focuses on different SQL concepts such as basic queries, aggregations, joins, subqueries, and optimization techniques. This resource is designed to help individuals master SQL coding through practical exercises.

Uploaded by

ranjankaul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

50 SQL Questions to Master SQL Coding

Beginner Level (Basics & SELECT statements)

1. Write a query to fetch all columns from the employees table.

2. Retrieve the names of employees from the employees table.

3. Select all distinct job titles from the jobs table.

4. Count the number of employees in the employees table.

5. Find the average salary from the employees table.

6. Get the maximum salary offered in the company.

7. List employees with salary greater than 50000.

8. Fetch employees whose name starts with 'A'.

9. Select employees hired after January 1, 2020.

10. Sort the employee list by salary in descending order.

Intermediate Level (Aggregations, Joins, Grouping)

11. Count employees in each department.

12. Show total salary expense per department.

13. List departments having more than 5 employees.

14. Get the second highest salary from employees.

15. Retrieve employees who earn more than the average salary.

16. Show the highest salary in each job title.

17. Get employee names and their manager names.

18. List employees who don't have a manager.

19. Get department names and their employee count using JOIN.

20. Find all employees who joined in the same month.

Advanced Level (Subqueries, Window Functions, CTEs)

21. Write a query to find the 3rd highest salary.

22. Get the Nth highest salary using a subquery.

23. Use RANK() to rank employees by salary within each department.


50 SQL Questions to Master SQL Coding

24. Use DENSE_RANK() to get top 3 salaries in each department.

25. Use ROW_NUMBER() to find duplicate entries in a table.

26. Find employees who have the same salary.

27. Get cumulative salary per department ordered by date of joining.

28. Write a recursive CTE to build a hierarchy of employees and managers.

29. Get the salary difference between each employee and department average.

30. Show employees with the maximum salary in their department.

Complex Real-World Scenarios

31. Identify departments with no employees.

32. Find employees who joined in the last 30 days.

33. List employees who have not been assigned any project.

34. Get the total number of projects handled by each employee.

35. Retrieve employees who work on more than one project.

36. List the top 5 departments by total salary expense.

37. Get a list of employees who haven't received a bonus.

38. Calculate year-over-year growth in employee count.

39. List customers who haven't placed any orders.

40. Generate a monthly report of sales.

Expert & Optimization

41. Use EXISTS to find employees who are assigned to projects.

42. Use NOT EXISTS to find customers with no orders.

43. Find employees who are the only one in their department.

44. Write a query using CASE to label salaries as 'High', 'Medium', 'Low'.

45. Explain how to optimize a slow query with indexes.

46. Use PIVOT to show sales data in a monthly format.

47. Flatten a nested structure using UNNEST() in BigQuery.

48. Write a query to detect gaps in date sequences.


50 SQL Questions to Master SQL Coding

49. Perform data deduplication using window functions.

50. Write a query to find the running average of sales for each day.

You might also like