Business Analyst
Technical BA
easy
Write a SQL query to find the second-highest salary in an employees table.
Asked at
InfosysTCSAccentureDeloitte
Framework
correlated subquery vs window function
Model answer
SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees); Or use DENSE_RANK() OVER (ORDER BY salary DESC) and filter rank = 2 — the ranked version handles ties correctly.
What great candidates actually do
- The subquery approach fails on ties — mention this before they ask.
- In interviews, always ask: 'Do duplicates count as the same rank?'
- DENSE_RANK vs RANK vs ROW_NUMBER — know when to use each.
Traps to avoid
- Naming the solution before the problem — always restate the goal in one sentence first.
- Answering without structure — pick a framework out loud, then execute it.
- Skipping the trade-off — every strong answer names what you would NOT do and why.
Related questions
Requirements
Walk me through the last BRD you wrote — how did you structure it?
Read answer →Requirements
What's the difference between a BRD, FRD and SRS — and when would you use each?
Read answer →Stakeholder
How would you elicit requirements from a senior stakeholder who won't give you time?
Read answer →
Practice with a human
Rehearse this out loud.
Book a 1:1 mock interview. Detailed feedback sheet + scoring on the exact rubric hiring managers use.
Book a mock interview