DataCareerHub
Explore learning
← Practice challengesFree companion · 15 minute suggested activity

Rank completed orders reproducibly

SQL practice · Retail case · 15–20 minutes. Start with retail-setup.sql in a disposable local SQLite database.

Learn → Try → ExplainReviewed 2026-10-15
01

Your task

Rank orders by value and break ties by order_id. Return only the top three. Write the query before opening the solution. Record the expected output grain.

02

Hint

Apply the status filter before aggregation. State whether the result represents orders, channels or periods. Keep currency units explicit.

Worked solution

R05 18000; R02 15000; R06 12000. ROW_NUMBER gives distinct positions; use DENSE_RANK only when ties should share a rank.

SELECT order_id,net_cents,ROW_NUMBER() OVER(ORDER BY net_cents DESC,order_id) value_rank FROM orders WHERE status='completed' ORDER BY value_rank LIMIT 3;
04

Check your reasoning

Reconcile the result to the source and describe one limitation. This tiny fictional dataset cannot establish customer behavior or predict future sales.

Make the reasoning yours.

Try the activity before reading its reference. Keep your sources, commands and assumptions with your work. Companion activities are unsaved self-practice and do not award a certificate or change lesson progress.

Resume guidance and examples are for learning and preparation only. They do not guarantee interviews, a job offer or employment.

Public registration, payments and new paid enrolment remain disabled. These free resources do not grant access to protected course modules.

Learner dashboard ↗ · Ask a question ↗