The Data Foundry

Built by Data with Pranjal

← Back to labs

SQL Lab

Browser-based data engineering practice.

Run code directly in your browser. No backend judge, no hidden server state: inspect the data, write the fix, run checks, then explain the production lesson.

Labs

294

Free

80

Runtime

SQLite

beginnerSQLRanking

SQL 1: Second Highest Salary

You are validating a warehouse query before it is promoted into a production analytics mart. This lab is written like a real analytics ticket: understand the required grain, inspect the sample data, then write a query that survives messy production-style edge cases.

Data engineer task

Return exactly the requested result set. The browser will compare your output with the model query. After you submit, the browser runs your SQL against the visible sample plus an additional edge-case dataset.

Expected outcome

Columns: second_highest_salary. Grain: one overall metric row. Business rule: return the second highest distinct salary, not the second employee row.

Sample production data

employees

emp_idemp_namedepartmentmanager_idsalary
1AshaDataNULL120000
2BenData1105000
3ChenData1105000
4DiyaAnalytics190000
5EvanAnalytics482000
6FatimaPlatform1115000
7GopalPlatform676000

Fix workspace

Write a read-only query that returns the expected result.

Saved locally