FOCUSED INTERVIEW PRACTICE · DOWNLOADABLE PDF

SQL · 7+ years interview questions & answers

Practise SQL queries, multi-table joins and interview scenarios. Check your approach against a numbered answer sheet with SQL solutions and short explanations.

220 questions68 PDF pages7+ years experience
₹259One-time payment · one PDF
Buy this PDF · ₹259Preview before you buy ↓

Model answers included · No account required · Private download after successful payment

SEE WHAT YOU WILL PRACTISE

Sample questions from this PDF

Try the questions first. Open the model answer below to see the explanation and SQL solution.

Sample 1

Using Customers, Orders, OrderLines and Products, compare all existing-order line value with matched-customer-and-product line value. Return both totals and the excluded difference in one row.

Read the model answer from this PDF

Separate scope reconciliation from join tuning; invalid lookup links must not disappear silently.

Example schema: Orders(order_id, customer_id), OrderLines(order_id, product_id, quantity, unit_price), Customers(customer_id), Products(product_id). Lookup IDs are unique; quantities and prices are non-NULL.

SELECT
  COALESCE(SUM(l.quantity * l.unit_price), 0) AS all_value,
  COALESCE(SUM(CASE
    WHEN c.customer_id IS NOT NULL AND p.product_id IS NOT NULL
    THEN l.quantity * l.unit_price ELSE 0 END), 0) AS matched_value,
  COALESCE(SUM(CASE
    WHEN c.customer_id IS NULL OR p.product_id IS NULL
    THEN l.quantity * l.unit_price ELSE 0 END), 0) AS excluded_value
FROM Orders o
JOIN OrderLines l ON l.order_id = o.order_id
LEFT JOIN Customers c ON c.customer_id = o.customer_id
LEFT JOIN Products p ON p.product_id = l.product_id;

SQL formatting is expanded for readability. Check syntax for your database.

Sample 2

Given PrimaryOrders(order_id,customer_id) and ReplicaOrders with unique IDs, join Customers to list primary order IDs missing on the replica. Use supplied snapshots in one database.

Sample 3

Using Customers, Orders, OrderLines and Products, report customer-level total line value and excluded value from missing products. Keep known customers' lines even if the product lookup is bad.

Your revision, organised

  • 220 numbered questions across 20 topics
  • Numbered answer sheet for checking your reasoning
  • Clickable topic index for focused revision
  • 68 PDF pages to save and study at your pace
See all topics in this PDF
  • Query results and business rules · 11 questions
  • Query plans and row estimates · 11 questions
  • Advanced indexing strategy · 11 questions
  • Partitioning and pruning · 11 questions
  • Isolation and serializability · 11 questions
  • MVCC and long transactions · 11 questions
  • Distributed consistency and sharding · 11 questions
  • Replication and read routing · 11 questions
  • Incremental computation and CDC · 11 questions
  • Slowly changing dimensions and temporal joins · 11 questions
  • Stored summaries and cache freshness · 11 questions
  • Memory, spills and parallelism · 11 questions
  • Window-query correctness at scale · 11 questions
  • Schema evolution and online migrations · 11 questions
  • Security and tenant isolation · 11 questions
  • Stored routines and transaction scope · 11 questions
  • Monitoring and query diagnostics · 11 questions
  • Backup, restore and disaster recovery · 11 questions
  • Analytical architecture and cost · 11 questions
  • Senior design and incident scenarios · 11 questions

A curated practice bank of independently written exercises and adapted public interview themes. These are not verified questions from particular companies. Experience bands indicate practice depth.

Try free SQL interview questions

Practise the fundamentals, explain a scenario and compare your approach with a short answer.

Read the SQL interview practice guide