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
53 practiced
Write an SQL query to compute the 95th percentile of page load time per browser for the last 30 days using `page_loads(browser, load_time_ms, ts)`. Provide an approach for databases that do not support percentile functions, and explain accuracy trade-offs.
EasyTechnical
74 practiced
Write a SQL query that returns the latest order per customer (latest by order_date) including customers with no orders (nulls for order info). Given `customers(customer_id, name)` and `orders(order_id, customer_id, order_date, total_amount)`, return `customer_id`, `name`, `last_order_date`, `last_order_amount`.
MediumTechnical
113 practiced
You observe a slow analytic query and want to inspect its execution plan. Explain key fields you look for in an EXPLAIN ANALYZE output (e.g., sequential scan, index scan, hash join, cost, rows, actual time) and how each informs optimization decisions.
MediumTechnical
70 practiced
Describe SQL patterns and best practices for securing sensitive columns (PII) in analytics queries and BI dashboards: masking, tokenization, column-level permissions, and how to handle joins when keys are tokenized. Provide concrete SQL examples for masking email and showing only domain to non-privileged users.
EasyTechnical
70 practiced
Write an SQL query to find customers who have never placed an order. Given `customers(customer_id, email)` and `orders(order_id, customer_id)`, return `customer_id`, `email`. Exclude customers with any orders. Use ANSI SQL and explain why you chose LEFT JOIN vs NOT EXISTS.

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.