Product Launch Day

ASKED IN INTERVIEW
4pts
Apple

Problem Statement

Apple retail analysts are evaluating the initial market reception of the latest iPhone lineup. You are provided with sales records for various products. Your task is to calculate the total units sold on the official launch day for the iPhone 16 and compare it to the launch day sales of the iPhone 15.

Launch Dates:

  • iPhone 15 Launch Day: 2023-09-22
  • iPhone 16 Launch Day: 2024-09-20

Rules:

  • Only consider sales where the product_name matches exactly iPhone 15 or iPhone 16.
  • The comparison must be based specifically on the launch dates provided above.
  • Output columns: iphone_15_launch_sales, iphone_16_launch_sales, sales_growth.
  • sales_growth is calculated as: iphone_16_launch_sales - iphone_15_launch_sales.

Table Schema:

  • Products: product_id, product_name, category, launch_price.
  • Sales: sale_id, product_id, sale_date, quantity_sold, store_id.
Tests your understanding of
Common Table Expressions, Join, DateTime and Window Functions

Input Tables

Products
product_id(INTEGER)product_name(VARCHAR)
101iPhone 15
102iPhone 16
103MacBook Air
Sales
sale_id(INTEGER)product_id(INTEGER)sale_date(DATE)quantity_sold(INTEGER)
11012023-09-22500
21012023-09-22350
31022024-09-20600
41022024-09-20420
51012023-09-23100
61022024-09-21150

Expected Output

iphone_15_launch_sales(INTEGER)iphone_16_launch_sales(INTEGER)sales_growth(INTEGER)
8501020170

Tags

MediumASKED IN INTERVIEWCommon Table ExpressionsJoinDateTimeWindow Functions
15-20 min
55%

Hints