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.

MediumTechnical
114 practiced
Write SQL to compute median and 90th percentile session durations from a sessions table(session_id, user_id, duration_seconds). Use percentile_cont or equivalent. Describe how percentile functions behave with ties and small samples, and alternatives if your DB doesn't support percentile functions.
HardTechnical
66 practiced
As PM, propose an SQL-side data governance plan to prevent PII leakage in analytics. Explain role-based access, row-level security, column masking, anonymization (hashing/tokenization) strategies, and how to enforce via views, policies, and audit logs.
HardTechnical
70 practiced
Write SQL to compute the top 10 products that increased the most in revenue rank between week N-1 and week N. Use transactions(product_id, amount, occurred_at). Output product_id, rank_last_week, rank_this_week, rank_change.
HardTechnical
71 practiced
Given an experiment assignment table assignments(user_id, experiment_id, variant, assigned_at) and events(user_id, occurred_at, event_name), write SQL to compute 7-day retention for treatment vs control. Describe how you'll handle users who cross over variants or are reassigned after events.
EasyTechnical
66 practiced
What is a Common Table Expression (CTE) in SQL and when should you use it? Provide a short example CTE that computes weekly new_users and explain readability and potential performance considerations.

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.