SQL Query Fundamentals Questions

Core SQL for reading and shaping data: SELECT, filtering with WHERE, sorting, DISTINCT, and single-table aggregation with GROUP BY, HAVING, and aggregate functions. Covers reasoning about NULL handling, grouping semantics, and writing correct queries against a given schema. The baseline query-writing surface most data and engineering interviews open with.

EasyTechnical
41 practiced

A user reports that SELECT * FROM orders WHERE customer_id = 12345; returns no rows, but you know customer_id 12345 exists. List at least four distinct reasons this can happen and the SQL checks you would run to diagnose each.

EasyTechnical
73 practiced

A colleague runs SELECT * FROM hires WHERE hire_date = '2024-03-10'; against a TIMESTAMP column holding values like '2024-03-10 09:15:00' and gets no rows. Explain why, and give two correct ways to find all hires on 2024-03-10.

MediumTechnical
51 practiced

Describe how to write a parameterized SQL query for a report where the user can optionally filter by product_category and/or region. Show a template using placeholders, and how to make the filter a no-op when a parameter is NULL or not provided.

MediumTechnical
46 practiced

Given orders(order_id, customer_id, amount, order_date) and vip_customers(customer_id), write a query returning orders placed by VIP customers using IN (subquery), then an equivalent using EXISTS, then an equivalent using JOIN. Discuss the performance and semantic considerations among the three for large tables.

EasyTechnical
52 practiced

Explain the difference between COUNT(), COUNT(1), COUNT(column), and COUNT(DISTINCT column). Give an example table where COUNT(column) and COUNT() return different values, explain how NULLs affect each form, and note when an optimizer treats COUNT(1) and COUNT(*) identically.

Unlock Full Question Bank

Get access to all 27 SQL Query Fundamentals interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.