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

Given users(user_id, name, country) and orders(order_id, user_id, amount, occurred_at), write a query computing total revenue and distinct-buyer count per country for the last 30 days, including countries with zero revenue (not just zero-activity time periods).

EasyTechnical
56 practiced

Given orders(order_id, customer_id, order_date, total_amount), write a query returning for each customer: first_order_date, last_order_date, total_orders, and lifetime_value (SUM of total_amount). Why are MIN/MAX useful for customer lifecycle reporting?

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.

MediumTechnical
51 practiced

Describe how to write a parameterized SQL query for a report where the user can optionally filter by product_category and/or region. Show a template using placeholders, and how to make the filter a no-op when a parameter is NULL or not provided.

EasyTechnical
49 practiced

Discuss the trade-offs of referring to GROUP BY columns by ordinal position (GROUP BY 1, 2) versus repeating the full expression versus using a CTE/alias. When is each acceptable in production SQL?

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.