Interview Q&A / PostgreSQL
PostgreSQL interview questions
Indexes, EXPLAIN, transactions and isolation, JSONB and the Postgres specifics backend interviews probe.
Prefer rapid revision? Practise PostgreSQL short interview answers →
- How do you get the top 2 highest-paid employees in each department?
Number the rows within each department using ROW_NUMBER or DENSE_RANK with PARTITION BY dept ORDER BY salary DESC, then filter on that number in an outer query. A lateral join is an alternative.
IntermediateQuick answer1 min read