PL/SQL problems

Problems solved with Oracle PL/SQL: procedures and functions over a small schema, each with example data and the expected output. Every solution was run on Oracle Database Free 23.26.

Each folder has a README.md (the problem, an example, the approach), a solution.sql, and either a schema.sql with its own tables and data, or a dependency on the shared Northwind data. The lessons are 16j–16m.

Problem Technique
Customer Orders nested cursors, parameterized cursor
Customer Tiers grouped count, LEFT JOIN for zero counts, CASE
Category Correlation self-join on order lines, counting unordered pairs
Employee Productivity ratios to period totals in one grouped query
Region Report top-1 with ROWNUM, top-10 with FETCH FIRST
Restock Report joins as filters, NO_DATA_FOUND
Ski School Assignment nested cursors vs one INSERT ... SELECT with HAVING
Five-a-Side Teams stateful cursor loop, user-defined exception
Costliest Hospital Stay cost formula in the cursor, fetch only the first row
Operator Rating two sums folded into one with a ±1 factor
Most Livable Cities two-step ranking with CTEs, pivot with CASE
Comics Correlation IN subquery vs a multiplying join
Protein Score weight table as one CASE, average of averages
Book Royalties interval overlap, cursor with parameters
Election Results top-N per group with %ROWCOUNT