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

Given orders(order_id, created_at TIMESTAMP), explain why filtering March 2024 with created_at BETWEEN '2024-03-01' AND '2024-03-31' can miss rows, since created_at includes a time-of-day. Write a correct, index-friendly query using a half-open range instead.

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.

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.

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

Describe the practical differences between DELETE, TRUNCATE, and DROP. Cover transactional behavior and rollback, performance, permission requirements, and whether triggers fire for each.

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.