PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates proficiency in data manipulation and analytical querying with SQL/Python, emphasizing date-based windowing, join operations, aggregation to identify maxima, and handling tied results.

  • easy
  • Wayfair
  • Data Manipulation (SQL/Python)
  • Data Scientist

Find top buyer in earliest 10-year window

Company: Wayfair

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Take-home Project

You are given two tables: `customers` and `purchases`. ### Table: `customers` | column | type | notes | |---|---|---| | customer_id | BIGINT | Primary key | | customer_name | VARCHAR | | | purchase_id | VARCHAR | Foreign key to `purchases.purchase_id` (assume 1 row per purchase) | ### Table: `purchases` | column | type | notes | |---|---|---| | purchase_id | VARCHAR | Primary key | | purchase_price | DECIMAL(10,2) | Purchase amount | | purchase_date | DATE | Date of purchase | ### Task Define the **earliest 10-year window** as the interval starting at the **minimum** `purchase_date` in `purchases` and ending 10 years later. Within that earliest 10-year window, find the customer(s) who have the **highest purchase price**. Return: - `customer_name` - `highest_price` (that customer’s max price within the window) If multiple customers tie for the highest price, return **all** of them. ### Output A result set with columns: `(customer_name, highest_price)`. ### Assumptions - Use the same timezone/calendar as stored dates (DATE, no timezone handling required). - The 10-year window is `[min_date, min_date + INTERVAL '10 years')` unless your SQL dialect requires a different but equivalent expression.

Quick Answer: This question evaluates proficiency in data manipulation and analytical querying with SQL/Python, emphasizing date-based windowing, join operations, aggregation to identify maxima, and handling tied results.

Last updated: May 7, 2026

Related Coding Questions

  • Clean scores and return top 5 students - Wayfair (easy)
  • Solve SQL and Python OA tasks - Wayfair (easy)

Loading coding console...

PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.