← Amazon Interview Insights

Amazon·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Amazon data analyst interview, came across a SQL-style question about revenue aggregated by customer city. Not much else to go on from what I remember.

Questions Asked (1)

Q1

Write a query to calculate total revenue broken down by customer city.

Product Analytics & MetricsData Modeling
Author's notes

Pretty standard aggregation question.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema and business definitions (e.g., revenue = quantity * price, city from customer address). Then write a SQL query that joins customers, orders, and order items, groups by city, and sums revenue. Finally, discuss handling edge cases like null cities and performance considerations.

Pro tip: Mention that you'd validate the query against a sample dataset or use a subquery to pre-aggregate revenue per order to avoid fan-out issues. Also, consider adding a comment on how you'd handle cities with no orders (e.g., using LEFT JOIN if needed).

1. Clarify requirements and schema

Ask about the tables involved (e.g., customers, orders, order_items) and how revenue is defined (e.g., quantity * unit_price). Confirm that 'city' comes from the customer's address.

2. Identify necessary joins

Determine the join path: customers to orders (on customer_id), orders to order_items (on order_id). Ensure you use INNER JOINs to only include orders with revenue.

3. Write the aggregation query

Use SUM(quantity * unit_price) as total_revenue, GROUP BY customer city, and ORDER BY total_revenue DESC for readability. Include customer city in the SELECT.

4. Address edge cases and performance

Discuss handling NULL cities (e.g., COALESCE to 'Unknown'), and mention indexing on join keys and city for performance. Consider pre-aggregating order totals to avoid large intermediate results.

5. Validate and explain

Walk through a sample result, explain how you'd test the query, and mention any assumptions made (e.g., currency, date range).

Key Points to Mention

  • Correct join path: customers → orders → order_items
  • Revenue calculation: SUM(quantity * unit_price)
  • GROUP BY customer city and ORDER BY total_revenue DESC
  • Handling NULL or missing cities (e.g., COALESCE)
  • Performance considerations: indexes on join keys, pre-aggregation
  • Assumptions about data (e.g., no returns, currency uniformity)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.