← Walmart Interview Insights

Walmart·Data Scientist·Online Assessment (OA)·Intermediate

Intermediate
Jul 2026Remote

Summary

Online assessment for a Data Scientist role, heavy on PostgreSQL window functions and statistical aggregations. Four SQL tasks back to back, each one a bit more painful than the last.

Questions Asked (4)

Q1

Given a multi-section online assessment schema (candidates, submissions, questions, responses), write a query to compute per-subtype accuracy and median response time for each attempt, filtering to attempts with at least 15 verbal responses. Also return total verbal response count and total time per attempt.

Product Analytics & MetricsData Modeling
Author's notes

The median part is what got me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema and definitions (e.g., what 'subtype' refers to, how to compute accuracy and median response time). Then outline a query that joins the necessary tables, aggregates per attempt and subtype, and applies the filter using a HAVING clause. Finally, discuss how to compute median in your SQL dialect (e.g., PERCENTILE_CONT) and ensure the output includes the required totals.

Pro tip: Mention that median response time should be computed using a window function or percentile function, and be explicit about handling ties or nulls. Also, note that filtering after aggregation (HAVING) is more efficient than filtering in a subquery when possible.

1. Clarify schema and definitions

Ask clarifying questions about the tables: how are attempts identified? What defines a 'verbal' response? How is accuracy calculated (e.g., correct/total)? Confirm the meaning of 'subtype' (e.g., question subtype).

2. Identify required joins and filters

Determine which tables to join (e.g., submissions to responses, responses to questions) and the filters needed (e.g., response type = 'verbal'). Ensure you can compute per-attempt and per-subtype metrics.

3. Compute per-subtype metrics

Write a subquery or CTE that groups by attempt and subtype, calculating accuracy (e.g., AVG(is_correct)) and median response time (using PERCENTILE_CONT or equivalent).

4. Aggregate totals and apply filter

In the main query, join the per-subtype metrics with totals per attempt (count of verbal responses, total time). Use a HAVING clause to filter attempts with at least 15 verbal responses.

5. Format and validate output

Ensure the final result includes attempt ID, subtype, accuracy, median response time, total verbal count, and total time. Discuss potential edge cases (e.g., attempts with no verbal responses) and how to handle them.

Key Points to Mention

  • Use of window functions or PERCENTILE_CONT for median calculation, noting dialect differences (e.g., PostgreSQL vs. MySQL).
  • Importance of filtering on verbal responses before aggregation to avoid skewing metrics.
  • Handling of attempts with fewer than 15 verbal responses via HAVING clause after grouping.
  • Inclusion of total verbal response count and total time per attempt, possibly using SUM and COUNT with appropriate filters.
  • Consideration of performance: using CTEs for readability and efficiency, and indexing on join keys.
  • Clarifying whether accuracy is per response (binary) or per question, and how to handle multiple responses per question.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Flag 'rushing' attempts where more than 20% of verbal responses have a response time under 15 seconds. Return attempt_id, candidate_id, and the rushing rate.

Product Analytics & Metrics
Author's notes

Simpler than the others.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the data model and assumptions (e.g., what counts as a verbal response, how to handle missing response times). Then outline a SQL-based solution using conditional aggregation to compute the rushing rate per attempt, filtering for attempts where the rate exceeds 20%.

Pro tip: Mention edge cases like attempts with very few responses (e.g., <5) where the rate can be noisy, and suggest a minimum response threshold to avoid false positives. Also, discuss how to handle multiple responses per question or non-verbal responses.

1. Clarify definitions and assumptions

Define what constitutes a 'verbal response' and a 'rushing' response (response time < 15 seconds). Confirm whether response time is in seconds and if there are any data quality issues.

2. Identify relevant tables and fields

Locate the table containing attempt_id, candidate_id, response time, and response type. Ensure you can join to filter only verbal responses.

3. Compute rushing rate per attempt

Use conditional aggregation: COUNT of responses with time < 15 seconds divided by total verbal responses, grouped by attempt_id and candidate_id.

4. Filter attempts exceeding threshold

Apply a HAVING clause to keep only attempts where the rushing rate > 0.20 (20%).

5. Return required columns

Select attempt_id, candidate_id, and the computed rushing rate (as a decimal or percentage).

Key Points to Mention

  • Use of conditional aggregation (SUM(CASE WHEN ...) / COUNT(*)) to compute the rate.
  • Filtering only verbal responses (e.g., response_type = 'verbal').
  • Handling attempts with zero verbal responses (avoid division by zero).
  • Considering a minimum number of responses to avoid unreliable rates.
  • Using HAVING clause to filter after aggregation.
  • Rounding or formatting the rushing rate for readability.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

Within the verbal section, find the subtype with the strongest absolute Pearson correlation between response time and correctness. Return subtype, correlation value, and sample size n. Use PostgreSQL's built-in corr() function.

A/B Testing & ExperimentationProduct Analytics & Metrics
Author's notes

I actually didn't know corr() was a native postgres aggregate before this.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Write a SQL query that filters the data to the verbal section, groups by subtype, and computes the Pearson correlation between response time and correctness using PostgreSQL's corr() function. Then order the results by the absolute correlation value in descending order and limit to the top row to get the subtype with the strongest correlation, along with the correlation and sample size.

Pro tip: Always check for nulls and ensure you're using the correct columns for response time and correctness; also consider whether correctness is binary (0/1) and if correlation is appropriate, but since the question specifies Pearson, proceed as instructed.

1. Filter to verbal section

Use a WHERE clause to restrict the data to rows where the section is 'verbal' (or equivalent).

2. Group by subtype

Group the filtered data by the subtype column to compute correlation for each subtype separately.

3. Compute correlation and sample size

Use corr(response_time, correctness) to calculate the Pearson correlation and COUNT(*) to get the sample size for each subtype.

4. Order by absolute correlation

Order the results by the absolute value of the correlation in descending order to find the strongest relationship.

5. Select top result

Limit the output to 1 row to return the subtype with the strongest absolute correlation, along with the correlation value and sample size.

Key Points to Mention

  • Use of PostgreSQL's corr() function for Pearson correlation
  • Filtering by section = 'verbal'
  • Grouping by subtype
  • Computing absolute correlation using ABS()
  • Ordering descending and limiting to 1
  • Including sample size with COUNT(*)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

For each candidate, compute verbal questions per minute and correct answers per minute from their most recent attempt only. Then rank candidates within their location by correct per minute, breaking ties using lower average time per question.

Data ModelingAlgorithms & Data Structures
Author's notes

This one had layers.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Break the problem into two phases: first, isolate each candidate's most recent attempt using a window function or correlated subquery, then compute verbal questions per minute and correct answers per minute. Next, rank candidates within each location by correct per minute, using average time per question as a tiebreaker, and ensure the final output includes the computed metrics and rank.

Pro tip: When computing per-minute rates, be careful with time units—convert seconds to minutes consistently. Also, clarify how to handle ties in 'most recent attempt' if multiple attempts share the same timestamp, and consider using DENSE_RANK or ROW_NUMBER based on business rules.

1. Identify the most recent attempt per candidate

Use a window function like ROW_NUMBER() OVER (PARTITION BY candidate_id ORDER BY attempt_date DESC) to select only the latest attempt for each candidate. Alternatively, use a correlated subquery with MAX(attempt_date).

2. Compute verbal questions per minute and correct answers per minute

Calculate verbal questions per minute as verbal_questions / (time_spent_seconds / 60.0) and correct answers per minute as correct_answers / (time_spent_seconds / 60.0). Ensure you handle division by zero if time_spent is zero.

3. Compute average time per question

Calculate average time per question as time_spent_seconds / total_questions (or verbal_questions if that's the relevant denominator). This will be used as a tiebreaker.

4. Rank candidates within each location

Use RANK() or DENSE_RANK() OVER (PARTITION BY location ORDER BY correct_per_minute DESC, average_time_per_question ASC) to assign ranks. Choose RANK or DENSE_RANK based on whether you want gaps for ties.

5. Output the final result

Select candidate_id, location, verbal_questions_per_minute, correct_answers_per_minute, average_time_per_question, and rank. Order by location and rank for readability.

Key Points to Mention

  • Use of window functions (ROW_NUMBER, RANK, DENSE_RANK) for both selecting most recent attempt and ranking.
  • Handling of time units: converting seconds to minutes consistently.
  • Tie-breaking logic: correct per minute descending, then average time per question ascending.
  • Partitioning by location for ranking.
  • Potential edge cases: zero time spent, missing data, multiple attempts with same timestamp.
  • Performance considerations: indexing on candidate_id and attempt_date, and avoiding unnecessary sorting.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.