FastPrepTop Five Countries by Product Revenue
Problems/Top Five Countries by Product Revenue

Top Five Countries by Product Revenue

Apple logoApple● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionConstraints

Problem statement

Source note: Reported in an Apple full-time phone screen. The report gives the revenue ranking and the tie-break rule. It does not give the full column types or the final order across the combinations. We chose those. Our version is about 96% the same as the reported question.

For each Apple product, find the five countries with the highest total sales revenue.

A line item contributes quantity * unit_price to its order country. Sum all line-item revenue for the same product and country.

Result

Return product_id, product_name, country_id, country_name, and sales_amount. Rank countries independently for each product by sales_amount descending. When amounts are equal, rank the country whose English country_name is alphabetically smaller first.

Return at most five rows per product. Order the final result by product_id ascending, then sales_amount descending, then country_name ascending.

Table schema

MySQLPostgreSQLPandas

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

ColumnTypeNullableDescription
product_idPKIntegerNo—
product_nameTextNo—
previous_model_idIntegerYes—

Foreign key: previous_model_id → products(product_id)

countries

ColumnTypeNullableDescription
country_idPKIntegerNo—
country_nameTextNo—

orders

ColumnTypeNullableDescription
order_idPKIntegerNo—
customer_idIntegerNo—
country_idIntegerNo—
order_dateDateNo—

Foreign key: country_id → countries(country_id)

order_items

ColumnTypeNullableDescription
order_idPKIntegerNo—
product_idPKIntegerNo—
quantityIntegerNo—
unit_priceDecimalNo—

Foreign key: order_id → orders(order_id)

Foreign key: product_id → products(product_id)

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
product_idIntegerNo—
product_nameTextNo—
country_idIntegerNo—
country_nameTextNo—
sales_amountDecimalNo—

Row order: must match exactly. Numeric tolerance: 0.

Constraints

  • Every quantity is a positive integer.
  • Every unit_price is a non-negative exact decimal.
  • Every product_name and country_name is unique.
  • Only product-country pairs with at least one line item appear in the result.
  • Each input table contains at most 2,000 rows.

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)
All Apple interview questionsSee Apple hiring insights