Scenario SQL Question
First and Latest Salary Per Employee (FIRST_VALUE / LAST_VALUE)
Build mastery in Ctes Window with this scenario-based SQL challenge and live execution support.
Problem Statement
For each employee in salaries_history, show every record alongside their first-ever salary and their latest salary. Beware the LAST_VALUE frame trap — use a full-partition frame. Return employee_id, effective_date, salary, first_salary, latest_salary — ordered by employee_id, effective_date.
Relevant Tables
salaries_history
SQL Concepts Used in This Scenario
Strengthen your understanding with these targeted learning topics: