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

What is the difference between GROUP BY and DISTINCT? Give one example where either works, and one example where GROUP BY with an aggregate is necessary because DISTINCT alone is insufficient.

HardTechnical
46 practiced

A global dashboard aggregates orders by day. Describe a strategy for correct daily aggregation across time zones: storing timestamps in UTC, converting to a target time zone at aggregation time, and handling daylight saving time. Give sample SQL computing daily revenue in a specific time zone (e.g., America/Los_Angeles).

EasyTechnical
40 practiced

Given products(product_id, name, category), write a query returning rows where category is one of 'electronics', 'appliances', or 'furniture'. Show it two ways: using IN and using chained OR comparisons. Which is clearer, and does it matter for performance?

HardTechnical
56 practiced

Explain why WHERE user_id NOT IN (SELECT user_id FROM deactivated_users) can return zero rows whenever the subquery returns even one NULL. Provide the corrected version using NOT EXISTS and an example demonstrating the difference.

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.