FastPrepCustomer Order Count Distribution by Country
Problems/Customer Order Count Distribution by Country

Customer Order Count Distribution by Country

Apple logoApple● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionConstraints

Problem statement

Source note: Reported in an Apple full-time phone screen. The report gives all three customer groups and says customers with no orders count too. It does not give the full column types or the order of the output. We chose those. Our version is about 97% the same as the reported question.

For every country, count its customers in three mutually exclusive order-frequency categories:

  • zero_order_customers: customers who have never placed an order.
  • one_order_customers: customers who have placed exactly one order.
  • multiple_order_customers: customers who have placed at least two orders.

Include every country, even when it has no customers. Customers with no matching row in orders must remain in the result.

Result

Return country_id, country_name, zero_order_customers, one_order_customers, and multiple_order_customers. Order rows by 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.

countries

ColumnTypeNullableDescription
country_idPKIntegerNo—
country_nameTextNo—

customers

ColumnTypeNullableDescription
customer_idPKIntegerNo—
country_idIntegerNo—

Foreign key: country_id → countries(country_id)

orders

ColumnTypeNullableDescription
order_idPKIntegerNo—
customer_idIntegerNo—
country_idIntegerNo—
order_dateDateNo—

Foreign key: customer_id → customers(customer_id)

Foreign key: country_id → countries(country_id)

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
country_idIntegerNo—
country_nameTextNo—
zero_order_customersIntegerNo—
one_order_customersIntegerNo—
multiple_order_customersIntegerNo—

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

Constraints

  • Each customer belongs to exactly one country.
  • Every order belongs to exactly one customer, and its country_id matches that customer's country.
  • Every country_name is unique.
  • A customer's category is based on the number of distinct order rows for that customer.
  • 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

  • Second Highest SalaryPaytm · PHONE SCREENPaytm interview questions
  • Employees Who Earn More Than Their ManagersNykaa · PHONE SCREENNykaa interview questions
  • Employees Who Joined More Than a Week AgoNewgen Software · PHONE SCREEN
  • Departments Without EmployeesDell Technologies · PHONE SCREENDell Technologies interview questions
  • Second-Highest Distinct SalaryChubb · PHONE SCREENChubb interview questions
  • Swap Two Gender ValuesInfosys · PHONE SCREENInfosys interview questions
  • Find Rows Common to Two TablesSalesforce · PHONE SCREENSalesforce interview questions
  • Count Records Present in A but Not BCapital One · PHONE SCREENCapital One interview questions
  • Employees Earning More Than Their ManagerMygate · PHONE SCREENMygate interview questions
  • Classify Tree Nodes with SQLOracle · PHONE SCREENOracle interview questions

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