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.

MediumTechnical
56 practiced

Given transactions(transaction_id, user_id, amount, occurred_at), write a query returning, per user, the total, average, minimum, maximum, and count of transaction amounts over the last 90 days, including only users with at least 3 transactions in the period, ordered by total descending.

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
53 practiced

Given orders(order_id, customer_id, order_date, total_amount), write a query finding duplicate orders based on the combination of (customer_id, order_date, total_amount), returning one representative order_id per duplicate group and the duplicate_count. Show the GROUP BY/HAVING approach, and mention how a window function offers an alternative.

MediumTechnical
49 practiced

Given orders(order_id, order_date, channel, total_amount), write a query producing monthly revenue with separate online_revenue and in_store_revenue columns, using conditional aggregation (SUM with CASE WHEN).

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.