Data Analyst interview questions
100 real questions with model answers and explanations for Junior candidates.
See a Data Analyst resume example →Practice with flashcards
Spaced repetition · Hunter Pass
Questions
A basic SELECT statement retrieves data from one or more tables.
- FROM chooses the source table, and WHERE filters individual rows.
- GROUP BY forms groups, and HAVING filters those groups after aggregation.
- ORDER BY sorts the result, and LIMIT caps the number of returned rows.
- The logical clause order helps explain query results and filter placement.
Why interviewers ask this: The interviewer checks that you understand query structure and evaluation order, not just that you can copy a query from a tutorial.
WHERE filters rows before grouping, while HAVING filters aggregated groups.
- WHERE country = 'DE' keeps only rows for Germany before aggregation.
- HAVING SUM(revenue) > 1000 keeps groups whose total exceeds 1000.
- Aggregate values do not yet exist when the WHERE stage runs.
- Put row conditions in WHERE and aggregate conditions in HAVING.
Why interviewers ask this: This classic filters out candidates who memorized syntax without understanding the order in which SQL processes a query.
GROUP BY combines rows with shared values so aggregates can be calculated per group.
- Grouping orders by customer_id creates one result group per customer.
- SUM(amount) can then calculate each customer's total spend.
- Without GROUP BY, an aggregate is calculated over the full result set.
- Selected columns must be grouped or placed inside an aggregate function.
Why interviewers ask this: Understanding aggregation granularity is the single most common source of wrong numbers in junior SQL, so interviewers probe it early.
INNER JOIN keeps matching rows only, while LEFT JOIN keeps every row from the left table.
- INNER JOIN removes left-side rows that have no match on the right.
- LEFT JOIN fills right-side columns with NULL when no match exists.
- A customer without orders disappears from an INNER JOIN result.
- Choosing the wrong join can silently change counts and totals.
Why interviewers ask this: A strong candidate explains the practical consequence for row counts and totals, not just the textbook definition.
To find the top 10 customers, aggregate revenue by customer and rank it from highest to lowest.
- Select customer_id and SUM(amount) from the orders table.
- Group by customer_id so each customer has one revenue total.
- Sort the revenue alias descending and apply LIMIT 10.
- Clarify gross versus net-of-refunds revenue before finalizing the ranking.
Why interviewers ask this: A bread-and-butter task where the interviewer watches for GROUP BY plus ORDER BY plus LIMIT and for a clarifying question about the revenue definition.
A count of all rows includes every row, while COUNT(column) excludes NULL values in that column.
- The two counts are equal only when the chosen column has no NULLs.
- After a LEFT JOIN, a customer without orders still produces one joined row.
- COUNT(orders.id) correctly returns zero for that customer's orders.
- Counting every joined row instead would quietly inflate the result.
Why interviewers ask this: This question filters candidates who know how NULLs interact with counting, a daily concern in real reporting.
The main aggregate functions summarize many rows into useful statistics.
- COUNT measures rows or non-NULL values, and SUM adds numeric values.
- AVG calculates the arithmetic mean, while MIN and MAX return extremes.
- GROUP BY applies these summaries separately to categories such as countries.
- Every common aggregate except a count of all rows skips NULL values.
Why interviewers ask this: Checks basic fluency with the everyday aggregation vocabulary of the job, including the NULL caveat.
DISTINCT removes duplicate result rows and keeps each selected value combination once.
- It applies to the full combination of selected columns, not only the first.
- Selecting one column with DISTINCT returns its unique values.
- COUNT(DISTINCT customer_id) counts unique buyers rather than orders.
- Use it deliberately because it can hide duplication caused earlier in a query.
Why interviewers ask this: The interviewer looks for the unique-buyers-versus-orders example, which shows you have used DISTINCT on a real business question.
ORDER BY sorts by each listed column in sequence.
- The first column defines the main order, and later columns break ties.
- Sorting is ascending by default, while DESC reverses a chosen column.
- ORDER BY country, revenue DESC ranks revenue within each country.
- Without ORDER BY, a database does not guarantee row order.
Why interviewers ask this: The last point about unguaranteed ordering separates people who have been bitten by real databases from those who have not.
NULL represents a missing or unknown SQL value, not zero or an empty string.
- Equality comparisons with NULL do not evaluate to true.
- Use IS NULL to find missing values and IS NOT NULL to exclude them.
- NULL values can change join matches and aggregate results.
- Check NULL rates in key columns before trusting an analysis.
Why interviewers ask this: Tests whether you understand three-valued logic in practice, since the = NULL mistake produces silently empty results.
Duplicate records can be found by grouping on the columns that should be unique.
- Group by a candidate key such as email and count its rows.
- Use HAVING with a count greater than one to keep duplicated values.
- The grouped result shows each duplicate key and its frequency.
- Join it back or use ROW_NUMBER to inspect the complete duplicate rows.
Why interviewers ask this: A practical staple; strong candidates produce the GROUP BY plus HAVING pattern without hesitation.
A subquery is a query nested inside another SQL query.
- It can appear in FROM, WHERE, or SELECT depending on the task.
- One use is comparing each customer's spend with an average calculated inside it.
- Subqueries work well for short, one-off pieces of logic.
- Replace deeply nested subqueries with CTEs when readability suffers.
Why interviewers ask this: The interviewer wants a concrete use case and awareness of when subqueries hurt readability.
A CTE is a named temporary result declared with WITH for use in the main query.
- It lets a complex query read as a sequence of clear steps.
- One CTE can clean data and a later CTE can aggregate it.
- The main query references each CTE much like a table.
- This top-to-bottom structure simplifies debugging and review.
Why interviewers ask this: Shows whether you write SQL that colleagues can maintain, which matters more than clever one-liners.
UNION and UNION ALL both stack compatible query results vertically.
- Each query must return matching numbers and compatible types of columns.
- UNION removes duplicate rows from the combined result.
- UNION ALL preserves every row and avoids the deduplication cost.
- Prefer UNION ALL when overlap is impossible or duplicates are meaningful.
Why interviewers ask this: A good answer covers both the semantic difference and the performance implication.
LIKE filters text by matching it against a pattern.
- A percent sign matches any sequence of characters.
- An underscore matches exactly one character.
- A pattern ending in @gmail.com can find Gmail addresses.
- For case-insensitive matching, use the database's ILIKE or normalized lowercase text.
Why interviewers ask this: The case sensitivity caveat distinguishes candidates who have actually cleaned messy text data.
CASE WHEN adds conditional logic to an SQL expression.
- It can label amounts as small, medium, or large.
- It supports conditional totals by returning an amount only for paid rows.
- An ELSE value handles rows that match no listed condition.
- CASE expressions can be used in SELECT, WHERE, GROUP BY, and ORDER BY.
Why interviewers ask this: The conditional aggregate pattern is the tell of someone who has built real pivot-style reports in SQL.
A primary key identifies each row, while a foreign key links rows through a referenced key.
- A primary key must be unique and non-NULL for every row.
- A foreign key references a primary or UNIQUE key, often in another table.
- Foreign-key values can repeat and may be NULL unless additional constraints apply; orders.customer_id can reference customers.id.
- Analysts use these constraints to understand join paths, relationship cardinality, and table granularity.
Why interviewers ask this: The interviewer checks whether you read a schema as a map of joins and granularity, not just as a list of tables.
Duplicate join keys can make a JOIN return more rows than either input table.
- SQL returns every matching pair rather than one row per original record.
- If a key appears twice on the left and three times on the right, the join returns six matching rows.
- Aggregating repeated amounts after such a join can inflate revenue or other totals.
- Check key uniqueness and expected relationship cardinality before joining, then compare row counts afterward.
Why interviewers ask this: Fan-out is the most common silent bug in analytical SQL, so a candidate who names the check stands out.
Filter the date column against the current date minus a 30-day interval.
- PostgreSQL can use order_date >= CURRENT_DATE - INTERVAL '30 days'.
- MySQL and BigQuery use different date subtraction syntax.
- Confirm whether the field is a date or a timestamp before filtering.
- Check time-zone and boundary rules so the intended days are included.
Why interviewers ask this: Date filtering looks trivial but hides time zone and boundary traps, and the interviewer wants to see that awareness.
IN tests membership in a list, while BETWEEN tests an inclusive range.
- IN is clearer than several OR conditions for values such as country codes.
- BETWEEN 10 AND 100 includes both 10 and 100.
- Inclusive endpoints are useful for simple numeric ranges.
- For timestamp ranges, prefer an explicit inclusive start and exclusive end.
Why interviewers ask this: The timestamp boundary caveat shows practical experience beyond syntax knowledge.
Locked questions
- 21
How do you aggregate daily data into monthly totals in SQL?
sqlaggregation - 22
What is a window function, and can you give a simple example useful for an analyst?
window-functions - 23
How do you join more than two tables in one query?
joinsqueries - 24
How do aggregate functions treat NULL values, and why does it matter?
aggregationfundamentals - 25
Before you send query results to a stakeholder, how do you check they are correct?
stakeholder-managementqueriescommunication - 26
What is the difference between mean, median, and mode, and when would you use each?
descriptive - 27
Why is median income usually reported instead of mean income?
descriptive - 28
How would you explain standard deviation in plain terms?
dispersion - 29
What is the difference between variance and standard deviation?
dispersion - 30
What are percentiles and quartiles?
percentiles - 31
What is an outlier, and how can you detect one with a simple rule?
outliers - 32
What is the difference between correlation and causation?
correlation - 33
What do correlation coefficients of 0.8, minus 0.8, and 0 tell you?
correlation - 34
What is a skewed distribution, and how does skew affect the mean and the median?
distributions - 35
What is the difference between a sample and a population, and why do we work with samples?
sampling - 36
What does a histogram show, and when do you use one?
distributions - 37
Overall average order value went up, but the average went down in every customer segment. How is that possible?
revenue - 38
What is the normal distribution, and why do analysts care about it?
distributions - 39
What do VLOOKUP and XLOOKUP do, and why is XLOOKUP considered better?
excel - 40
What is a pivot table, and when do you use one?
excel - 41
What is the difference between relative and absolute cell references in Excel?
excel - 42
What do SUMIF and COUNTIF do, and when do you reach for them?
excel - 43
How do you find and remove duplicates in a spreadsheet?
spreadsheetsspread - 44
How do you use conditional formatting in analysis?
excel - 45
Your VLOOKUP returns #N/A for values you can clearly see in the source table. What do you check?
excel - 46
How do you keep a working spreadsheet understandable for someone else?
spreadsheetsspread - 47
At what point does a spreadsheet stop being the right tool for an analysis?
spreadsheetsspread - 48
Which spreadsheet functions do you use to clean messy text data?
spreadsheetsspread - 49
How do you handle missing data in a dataset?
missing-datasoft-skills - 50
How do you decide between dropping rows with missing values and imputing them?
missing-data - 51
Walk me through the steps you take to clean a raw dataset before analysis.
cleaning - 52
A city column contains values like NY, N.Y., and New York. How do you fix it?
schema - 53
You receive dates in mixed formats like 03/04/2025 and 2025-04-03 from different sources. What do you do?
cleaning - 54
You found extreme outliers in order amounts. Do you remove them or keep them?
outliers - 55
Why document your data cleaning steps, and how do you do it?
cleaning - 56
After cleaning a dataset, how do you verify you have not broken anything?
validation - 57
You need to merge two customer lists, but the IDs do not match perfectly between systems. What do you do?
system-design - 58
Exact duplicate rows are easy to find. How do you catch near-duplicates, like the same customer entered twice?
dedup - 59
What is the difference between categorical and numerical data, and why does it matter?
data-types - 60
What is the difference between discrete and continuous variables?
data-types - 61
What dimensions would you use to describe the quality of a dataset?
quality - 62
How do you ensure data quality in your analyses?
quality - 63
How do you check that a column really is a unique identifier?
schema - 64
What problems appear when numeric values are stored as text?
data-types - 65
How do you choose the right chart type for your data?
chart-choice - 66
When do you use a bar chart versus a line chart?
charts - 67
Why do pie charts get so much criticism, and when is one acceptable?
charts - 68
What are common ways a chart can mislead, even unintentionally?
chart-integrity - 69
What makes a dashboard genuinely useful for a business user?
dashboards - 70
How should color be used in charts?
charts - 71
What is the difference between a histogram and a bar chart?
distributionscharts - 72
What does a scatter plot show, and when do you use one?
charts - 73
A stakeholder's chart has 12 lines and nobody can read it. How do you fix it?
stakeholder-managementcommunication - 74
How does your presentation of the same analysis differ between an executive and a fellow analyst?
- 75
What is the difference between a pandas DataFrame and a Series?
pandas - 76
You receive a new CSV file. What are your first steps in pandas?
pandas - 77
How do you filter rows in pandas, for example orders above 100 from Germany?
pandas - 78
How does groupby work in pandas?
pandas - 79
How do you join two DataFrames in pandas?
pandasjoins - 80
How do you work with missing values in pandas?
missing-datapandas - 81
What does df.describe() tell you, and what are its limits?
- 82
What do you use value_counts() for?
pandas - 83
What is the difference between loc and iloc in pandas?
pandas - 84
When do you reach for Python instead of Excel or SQL?
sqlpythonexcel - 85
What is conversion rate, and how do you calculate it?
conversion - 86
What are retention and churn, and why do they matter?
retentionchurn - 87
What are ARPU and average order value, and how do they differ?
revenue - 88
What are DAU and MAU, and what does their ratio indicate?
active-users - 89
What is funnel analysis?
funnel - 90
What makes a metric a good KPI?
monitoring - 91
A key metric dropped 20 percent overnight. What are your first steps?
monitoring - 92
Revenue is flat, but the business feels something changed. How do you decompose revenue to find out?
decomposition - 93
How do you explain a technical finding to a non-technical stakeholder?
communicationstakeholder-management - 94
How do you structure a written summary of an analysis?
- 95
A stakeholder asks a question your data cannot answer. What do you do?
stakeholder-managementcommunication - 96
How do you communicate uncertainty in your numbers without losing the audience?
communication - 97
Your manager says, look into our sales numbers. What do you do before opening a single table?
analysis - 98
Three teams send you urgent requests on the same morning. How do you prioritize?
prioritization - 99
You discover a mistake in a report you already sent out. What do you do?
ownership - 100
How do you keep developing your skills as a junior analyst?