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.

HardTechnical
83 practiced

Given orders(order_id, vendor_id, amount, status) and vendors(vendor_id, name), compute average order value per vendor, but only for completed orders and only for vendors with at least 100 such orders. Write the query, applying the status filter with WHERE (before aggregation) and the count threshold with HAVING (after aggregation), and explain why each belongs where it does.

MediumTechnical
40 practiced

SELECT category, product_name FROM sales GROUP BY category; raises an error about a non-aggregated column. Explain why, and give two different corrections depending on business intent: picking one representative product per category, versus listing every category/product pair.

EasyTechnical
55 practiced

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

EasyTechnical
50 practiced

Given customers(email VARCHAR), write a query returning customers whose email domain is gmail.com or yahoo.com, case-insensitively. Show the PostgreSQL ILIKE form and a portable form using LOWER() for databases without ILIKE.

EasyTechnical
73 practiced

Explain why WHERE phone = NULL returns no rows even when some rows have a NULL phone value. Write the correct query to select rows where phone IS NULL, and a second one for rows where it IS NOT NULL.

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.