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

Given orders(order_id, customer_id, order_date, total_amount), write a query returning for each customer: first_order_date, last_order_date, total_orders, and lifetime_value (SUM of total_amount). Why are MIN/MAX useful for customer lifecycle reporting?

MediumTechnical
54 practiced

Using De Morgan's laws, rewrite NOT (status = 'shipped' OR status = 'delivered') into an equivalent WHERE clause that has no top-level NOT. Why can rewriting boolean expressions like this help readability and the optimizer?

EasyTechnical
47 practiced

For SUM, AVG, COUNT, MIN, and MAX: what happens when the input set is all NULLs versus a mix of NULL and non-NULL values? How should a dashboard display these aggregates when you want zeros instead of NULLs?

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).

EasyTechnical
52 practiced

Given transactions(transaction_id, user_id, amount, transaction_ts), write a query computing total_sales (SUM), average_amount (AVG), and order_count (COUNT) per month for the last 6 months, ordered newest to oldest, omitting months with zero activity.

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.