Skip to content
Chapter Practice Arena

Advanced SQL Queries Problems

Targeted practice challenges specifically curated for this chapter. Inspect hints, verify outputs, and check verified solutions.

All Chapters
Filter by Language:12 Problems
Filter by SQL Chapter:
Difficulty:
Chapter:
Showing 6 challenges · 12 total · Page 1 of 2
Practical Example: Rank Employees by Salary
Starter Code
-- Practice query for Ranking with ROW_NUMBER, RANK, and DENSE_RANK
Expected Output
Formatted Result
employee_idemployee_namedepartmentsalaryrow_numsalary_ranksalary_dense_rank
1AshaEngineering90000111
2RaviEngineering85000222
3MeeraEngineering85000322
5NehaSales75000111
4KabirSales70000222
5 rows returned7 columns
#2advancedRecursive CTEs
Real-World Example: Employee Management Hierarchy
Starter Code
-- Practice query for Recursive CTEs
Expected Output
Formatted Result
employee_idemployee_namemanager_iddepthpath
1AshaNULL0{1}
2Ravi11{1,2}
3Meera11{1,3}
4Arjun22{1,2,4}
5Neha22{1,2,5}
6Kabir32{1,3,6}
6 rows returned5 columns
#3advancedRecursive CTEs
Cycle Detection in Hierarchical Data
Starter Code
-- Practice query for Recursive CTEs
Expected Output
Formatted Result
nodepath
1{1}
2{1,2}
3{1,2,3}
3 rows returned2 columns
5. Use CTEs with Filtering and Aggregation
Starter Code
-- Practice query for Common Table Expressions (CTEs)
Expected Output
Returns customers whose total amount across completed orders is at least 1000. Exact results depend on the schema, status values, and stored amounts.
#5advancedWindow Functions
PARTITION BY: Calculate Within Groups
Starter Code
-- Practice query for Window Functions
Expected Output
Formatted Result
sale_idemployeeamountemployee_total
1Asha100250
2Ravi200500
3Asha150250
4Ravi300500
4 rows returned4 columns
Top N With Ties: RANK and DENSE_RANK
Starter Code
-- Practice query for Ranking with ROW_NUMBER, RANK, and DENSE_RANK
Expected Output
Formatted Result
employee_namesalarysalary_ranksalary_dense_rank
Asha10000011
Meera9000022
Ravi9000022
3 rows returned4 columns