iPhone Model Sales Share by Country
Updated
Problem statement
Apple tracks iPhone orders by country. For every country and every model that names a previous-generation model, compare the two models' shares of that country's total iPhone units sold.
Return one row when either the current model or its previous model sold at least one unit in the country. A missing side of the comparison has zero units.
Result
Return country_name, product_name, current_share_percent, previous_share_percent, and share_difference_percentage_points. A model share is its units divided by all units sold in the same country, multiplied by 100 and rounded to two decimal places. The difference is current share minus previous share.
Order rows by country_name ascending, then product_name ascending.
Table schema
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
products
| Column | Type | Nullable | Description |
|---|---|---|---|
| product_idPK | Integer | No | — |
| product_name | Text | No | — |
| previous_model_id | Integer | Yes | — |
Foreign key: previous_model_id → products(product_id)
countries
| Column | Type | Nullable | Description |
|---|---|---|---|
| country_idPK | Integer | No | — |
| country_name | Text | No | — |
orders
| Column | Type | Nullable | Description |
|---|---|---|---|
| order_idPK | Integer | No | — |
| customer_id | Integer | No | — |
| country_id | Integer | No | — |
| order_date | Date | No | — |
Foreign key: country_id → countries(country_id)
order_items
| Column | Type | Nullable | Description |
|---|---|---|---|
| order_idPK | Integer | No | — |
| product_idPK | Integer | No | — |
| quantity | Integer | No | — |
| unit_price | Decimal | No | — |
Foreign key: order_id → orders(order_id)
Foreign key: product_id → products(product_id)
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| country_name | Text | No | — |
| product_name | Text | No | — |
| current_share_percent | Decimal | No | — |
| previous_share_percent | Decimal | No | — |
| share_difference_percentage_points | Decimal | No | — |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
- Every
quantityis a positive integer. - Every row in
productsrepresents one iPhone model, andproduct_namevalues are unique. - Every
previous_model_idis eitherNULLor identifies an older product. - Every
country_nameis unique. - Each input table contains at most
2,000rows.
More Apple Phone Screen questions
- Subarray Product Less Than KPHONE SCREEN · Seen Nov 2026
- Evaluate DivisionPHONE SCREEN · Seen Nov 2026
- Reverse a Linked ListPHONE SCREEN · Seen Nov 2026
- Validate a BST with a Custom ComparisonPHONE SCREEN · Seen Nov 2026
- Design a Food Rating SystemPHONE SCREEN · Seen Oct 2026
- Days Until Poisoned Plants StabilizePHONE SCREEN · Seen Oct 2026
- Capture Surrounded Regions with Union-FindPHONE SCREEN · Seen Oct 2026
- Maintain a Consistent-Hashing RingPHONE SCREEN · Seen Oct 2026
- Count Nodes in a ChainPHONE SCREEN · Seen Oct 2026
- Run-Length DecodingPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Nth Highest SalaryPaytm · PHONE SCREENPaytm interview questions
- Email Funnel: Opened Within a Day, Replied Within a WeekSuperhuman · PHONE SCREENSuperhuman interview questions
- Top Three Accounts by Monthly Transaction AmountMastercard · PHONE SCREENMastercard interview questions
- In-Memory Database QueriesOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
- Top Three Sales per County and YearClickhouse · PHONE SCREEN
- Block Type with the Most ChildrenNotion · PHONE SCREENNotion interview questions
- Third-Highest Known SalaryAdobe · PHONE SCREENAdobe interview questions
- Days Between Each User's Latest Two PostsZip · PHONE SCREENZip interview questions
- Observed-User Percentage by AppMicrosoft · PHONE SCREENMicrosoft interview questions
- Nth-Highest Book Sales VolumeAmazon · PHONE SCREEN
Apple interview experiences
- Apple SWE Phone Screen: Subarray Products: 1 Experience
- Apple New Grad SWE Java, Coding and Manager Rounds: 1 Experience
- Apple AI Coding and Related Interviews: 17 Experiences
- Apple India SWE New Grad Interviews: 5 Experiences
- Apple New Grad SWE Phone Screens: 12 Experiences (Part 3 of 3)
- Apple New Grad SWE and Embedded: 16 Experiences (Part 2 of 3)