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

Given events(event_id, user_id, event_type, occurred_at), write a query computing Daily Active Users (DAU) for the last 30 full days: count of distinct users per UTC day, treating multiple same-day events per user as one. Compare writing this with COUNT(DISTINCT ...) versus GROUP BY, and note performance considerations at scale.

EasyTechnical
39 practiced

Given users(user_id, name, email) and orders(order_id, user_id, total_amount, order_date), write a query listing name, email, order_id, and total_amount for orders over $100, including only users who have at least one such order.

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

Explain how implicit type casting and precision differences can affect GROUP BY behavior (e.g., grouping numeric-looking strings versus numeric types, or floating-point imprecision producing unexpected extra groups). What practical steps standardize group keys and avoid miscounts?

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.

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.