PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches

Quick Overview

This question evaluates proficiency in SQL data manipulation, including aggregations, date-range filtering, joins, window functions for ranking and tie-breaking, and computing revenue shares and growth rates within a relational schema.

  • Medium
  • Boston Consulting Group
  • Data Manipulation (SQL/Python)
  • Data Scientist

Query top spenders and 7-day growth

Company: Boston Consulting Group

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

Assume 'today' = 2025-09-01. Write a SQL query to: (1) for each model, compute total revenue in the last 7 days (2025-08-26 to 2025-09-01 inclusive) and the previous 7 days (2025-08-19 to 2025-08-25), excluding orders with status <> 'completed'; (2) for each model, list the top 3 customers by spend in the last 7 days with their spend and their percentage share of the model’s 7-day revenue; (3) report, per model, the 7-day-over-7-day revenue growth rate: (curr - prev)/NULLIF(prev, 0). Return: model_name, curr_revenue, prev_revenue, growth_rate, customer_id, customer_name, customer_spend, customer_share_pct. Break ties for top-3 by the earliest first purchase date of the customer on that model (use the full order history). Schema and small sample data: models model_id | model_name 1 | Sedan 2 | SUV customers customer_id | customer_name | country 101 | Alice | US 102 | Bob | US 103 | Chen | CN orders order_id | order_date | customer_id | model_id | qty | unit_price | status 1 | 2025-08-27 | 101 | 1 | 1 | 20000 | completed 2 | 2025-08-30 | 102 | 2 | 1 | 30000 | completed 3 | 2025-08-31 | 101 | 2 | 1 | 32000 | completed 4 | 2025-09-01 | 103 | 2 | 2 | 29000 | completed 5 | 2025-08-20 | 101 | 1 | 1 | 21000 | completed 6 | 2025-08-26 | 102 | 1 | 1 | 19000 | cancelled 7 | 2025-08-25 | 103 | 2 | 1 | 28000 | completed 8 | 2025-08-24 | 102 | 2 | 1 | 27000 | completed Notes: revenue = qty*unit_price. Use window functions for ranking, partitioning by model, and tie-breaking by first purchase date.

Quick Answer: This question evaluates proficiency in SQL data manipulation, including aggregations, date-range filtering, joins, window functions for ranking and tie-breaking, and computing revenue shares and growth rates within a relational schema.

Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,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.

Related Coding Questions

  • Transform messy transactions with pandas - Boston Consulting Group (Medium)
  • Unify 7 tables and impute missing values - Boston Consulting Group (Medium)
  • Manipulate and merge DataFrames correctly - Boston Consulting Group (Medium)
  • Transform and aggregate messy event data - Boston Consulting Group (Medium)
  • Merge and Concatenate Inconsistent Order Files with Pandas - Boston Consulting Group (Medium)