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.
Given page_views(user_id, page_id, viewed_at), compare using DISTINCT versus GROUP BY to compute the number of unique users per page. Which is more appropriate here, and why?
Given orders(order_id, customer_id, amount, order_date), write a query returning monthly revenue per customer using a month bucket (customer_id, month, monthly_revenue), ordered by customer then month.
Given users(email VARCHAR), write a query to find rows where the email column contains a literal underscore ('_') or percent ('%') character, not as a wildcard. Show how to escape these characters in a LIKE pattern.
When grouping by a dimension such as customer_segment that may contain NULLs, SQL groups all the NULLs together. Show how to COALESCE NULLs to 'Unknown' for a dashboard, how to still analyze the NULL group separately when needed, and what it means for joining the result back to a segment dimension table.
Explain the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN, with a short example of when each would be used.
Unlock Full Question Bank
Get access to all SQL Query Fundamentals interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.