InterviewStack.io LogoInterviewStack.io

SQL for Data Analysis Questions

Using SQL as a tool for data analysis and reporting. Focuses on writing queries to extract metrics, perform aggregations, join disparate data sources, use subqueries and window functions for trends and rankings, and prepare data for dashboards and reports. Includes best practices for reproducible analytical queries, handling time series and date arithmetic, basic query optimization considerations for analytic workloads, and when to use SQL versus built in reporting tools in analytics platforms.

HardTechnical
62 practiced
Explain how to implement incremental analytics using Change Data Capture (CDC) from OLTP to a data warehouse using SQL. Provide SQL patterns to apply CDC stream to fact and dimension tables, ensure idempotency, handle schema changes, and maintain watermarks for late-arriving records.
HardSystem Design
58 practiced
Design a partitioning and clustering scheme for a 2TB events table containing 3 years of clickstream (~100B rows). Queries usually filter by event_ts (time range) and sometimes by user_id. Provide recommended partition scheme (daily/monthly), clustering keys, and maintenance tasks (compaction, vacuum/analyze) to keep analytic queries fast.
HardSystem Design
75 practiced
Design materialized view refresh strategies for a near-real-time dashboard (<2 minutes latency) on 10TB of event data. Compare full refresh, incremental refresh, and streaming update to materialized views. Show SQL patterns (MERGE into mv) for incremental refresh and discuss consistency at scale.
HardTechnical
66 practiced
A scoring query computes top-100 users by a complex score that involves correlated subqueries and window functions over large fact tables. Rewrite the query into an efficient plan by pre-aggregating inputs into temporary tables, eliminating correlated subqueries, and computing window functions once. Provide example SQL rewrite and explain why it's faster.
HardTechnical
65 practiced
Write a single SQL solution that calculates, for every user and date, the number of unique active days in the preceding 30 days (rolling active-days). Input: `events(user_id, event_ts)`. You must deduplicate multiple events per day and optimize for large datasets (Postgres).

Unlock Full Question Bank

Get access to hundreds of SQL for Data Analysis interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.