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

Why should production dashboards and ETL queries avoid SELECT *? Give at least three concrete reasons (performance, schema drift, readability) with examples of better alternatives.

EasyTechnical
39 practiced

Write a PostgreSQL statement to insert into users(id, email, name, updated_at) or update the existing row on conflict of id (an upsert), updating name and setting updated_at = now(). Briefly describe the SQL Server MERGE alternative, and why upserts are useful for idempotent data loads.

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.

EasyTechnical
40 practiced

Given contacts(contact_id, email, phone), write a query finding rows where phone or email IS NULL, and a separate query for rows where they are empty strings (''). Explain why NULL and '' are different values in SQL and why IS NULL (not = NULL) is required to test for the former.

EasyTechnical
44 practiced

Explain the difference between UNION and UNION ALL. Given two same-shaped tables that may contain overlapping rows, write one query showing UNION removing duplicates and one showing UNION ALL preserving them, and discuss when each is preferable in a reporting or ETL pipeline.

Unlock Full Question Bank

Get access to all 27 SQL Query Fundamentals interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.