InterviewStack.io LogoInterviewStack.io

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

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?

EasyTechnical
38 practiced

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.

MediumTechnical
39 practiced

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.

MediumTechnical
44 practiced

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.

EasyTechnical
47 practiced

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 Continue

Join thousands of developers preparing for their dream job.