⌘K
Flycodx

Find Median Salary by Department

Find Median Salary by Department

HardSQL0% accepted

Given an Employee table with Department and Salary, find the median salary for each department. Use both the PERCENTILE_CONT approach and a row-count approach.

Approach

Calculate median salary per department using window functions.

Input

IT dept salaries: 100,200,300,400,500 (5 employees)

Output

Median = 300 (3rd of 5)

Scenarios & Expected Answers

Sign in to continue

Create a free account to view answers and mark progress.

  • Free forever — no credit card
  • Theory Q&A with detailed answers
  • Points, streaks & leaderboards
Auto Save On