Skip to content
Tech Interview Prep home
Technical interview guide

SQL Fundamentals

SELECT, WHERE, and JOIN — retrieving and combining rows from relational tables.

Read
24 min
Practice MCQs
25
Interview QA
25
Edition
v3
Editorial status
Reviewed

Scope: SQL principles with PostgreSQL 18 examples; vendor-specific behavior must be verified.

Interview QA

Treat each question like a live interview question: answer out loud first (structure, assumptions, tradeoffs), then open the model answer to spot gaps and rehearse a tighter follow-up.

Curated: · Written: · Reviewed:

QA-1

Walk through SQL's logical processing order and explain why it matters in practice.

QA-2

Explain NULL semantics in SQL and the bugs three-valued logic causes.

QA-3

A report's revenue total doubled after a new join was added. How do you diagnose it?

QA-4

How do you prevent SQL injection, and why is escaping insufficient?

QA-5

Compare OFFSET and keyset pagination for a large, frequently updated list.

QA-6

Which integrity rules belong in the database rather than the application, and why?

QA-7

When would you use a CTE, a subquery, or a temporary table?

QA-8

Write and explain a query that finds duplicate rows by a business key.

QA-9

Explain the difference between GROUP BY aggregation and a window function.

QA-10

How do you choose between INNER, LEFT, and FULL joins when assembling a report?

QA-11

A query returns correct results in testing but wrong ones in production. What do you check?

QA-12

What is a self join, and what is a classic scenario where you must join a table to itself?

QA-13

How would you approach a report query that has become too slow?

QA-14

Explain the difference between DISTINCT, GROUP BY, and DISTINCT ON.

QA-15

What is sargability, and how does it affect whether an index is used?

QA-16

How would you design soft deletion, and what does it cost?

QA-17

Explain how you would model a many-to-many relationship and query it.

QA-18

How do you write a query whose results are stable and reproducible?

QA-19

Explain the trade-offs of storing JSON in a relational database.

QA-20

How would you safely add a NOT NULL column to a large, live table?

QA-21

Explain the difference between UNION, INTERSECT, and EXCEPT with a practical use.

QA-22

What is the difference between a natural key and a surrogate key?

QA-23

What are transactions in SQL, and what does ACID guarantee in a relational database?

QA-24

Explain how you would find and fix an N+1 query problem originating in application code.

QA-25

Describe how you would review a colleague's SQL for a production report.