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
52 practiced
Running median by day: Given a transactions table (txn_date, amount), describe SQL approaches to compute the daily median transaction amount for the past year. Provide at least two strategies (exact and approximate) and discuss performance trade-offs on large datasets.
HardSystem Design
58 practiced
Design an analytical schema for an e-commerce analytics workload. Define fact and dimension tables, the grain of the main fact, and justify your choice. Include handling of product hierarchies, promotions, and multi-currency pricing in your design.
HardTechnical
61 practiced
Anomaly detection via SQL: Given a transactions table, write a SQL query (or describe one) to flag daily transaction totals that are statistical outliers vs the previous 30-day window. Return date, total_amount, z_score, is_outlier boolean (z_score threshold 3). Explain when this approach works and its limitations.
MediumTechnical
68 practiced
Explain differences between ROW_NUMBER(), RANK(), and DENSE_RANK() window functions. Provide SQL examples that demonstrate when each gives different results and a BI use case for each (e.g., top-N selection, handling ties in leaderboards).
HardTechnical
59 practiced
You're presented with a slow analytic SQL query. Describe the steps you take to diagnose and optimize it in a modern cloud data warehouse (e.g., BigQuery, Snowflake, Redshift). What metrics and tools do you use to find hotspots and what rewrite strategies are common?

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.