FunctionRacerProblemsRace

Rank in the Department

MediumSQLSQLite

Return every person's name, dept and salary, and rnk: their place in their own department by salary, 1 for the best paid. People on the same salary share a place, and the places after them are skipped: 1, 1, 3. Rows may come in any order.

Example 1

employees
idnamedeptsalary
1Adaops5000
2Benops5000
3Cyops4000
4Deerisk6000
5Elirisk3000
returns
namedeptsalaryrnk
Adaops50001
Benops50001
Cyops40003
Deerisk60001
Elirisk30002

Constraints

Race itor take your time

Write it in your browser, against the clock. The model query, with a note on each piece of it, comes after.

More SQL problems