Joins, aggregation, the second-highest-salary question, and window functions — the SQL that shows up again and again in technical rounds.
SQL is one of the highest-return topics for placements: a small, well-defined syllabus that appears in almost every technical round. A weekend of focused practice pays off disproportionately.
Know cold
- Joins —
INNER,LEFT,RIGHT,FULL. Be able to explain each with a two-table example. - Aggregation —
GROUP BYwithHAVING, and whyWHEREcannot filter aggregates. - Subqueries — correlated vs non-correlated.
The classics you will be asked
- Second-highest salary — via
LIMIT/OFFSET, a subquery, orDENSE_RANK(). Know at least two ways. - Nth-highest — generalise the above with a window function.
- Duplicate rows — find with
GROUP BY … HAVING COUNT(*) > 1. - Department-wise max — a join back to a grouped subquery.
Window functions
ROW_NUMBER(), RANK(), and DENSE_RANK() separate strong candidates from average ones. Understand how PARTITION BY resets the count. Write these queries by hand until the syntax is automatic — that is what the prephasz technical drills build.
Put this into practice
Drill these exact patterns with adaptive practice, timed mocks and company-wise assessments on prephasz.
Start practising free