Top 3 Sql Interview Questions
Browse 3 real-world technical and behavioral interview questions about Sql. Review scenarios, edge cases, and architectural best practices.
Find me every customer with no order in the last thirty days, then tell me which ways of writing that get NULLs wrong.
Use NOT EXISTS for customers with no recent order because it expresses an anti-join and avoids NULL traps. NOT IN can return no rows if the subquery contains NULL, and LEFT JOIN becomes wrong if filters are placed in WHERE. Use this SQL answer to show the decision, trade-off, and evidence rather than a memorised definition. It also connects null semantics to the point an interviewer is testing.
The customer's schema has no documentation and the person who designed it has left. How do you work out what the tables actually mean?
Read the data rather than the DDL: profile every column for cardinality, null rate and value distribution, use foreign-key-shaped joins to test relationships you suspect, and confirm each conclusion against a report the business already trusts before you build on it.
The business told you a field is always populated, and in production it is null for a third of the rows. How do you work out what is going on and what do you do about it?
Segment the nulls before drawing any conclusion — by date, source system, record type and creating process — because a null rate that clusters is a documented business path nobody mentioned, while one spread evenly is usually a genuine capture defect.