PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches

Quick Overview

This question evaluates competency in SQL-based data manipulation for a data scientist role, covering joins, aggregations, date-based filtering, metric computation, and use of window functions to derive week-over-week changes.

  • Medium
  • Amazon
  • Data Manipulation (SQL/Python)
  • Data Scientist

Calculate Defect Rate and Identify Top Lanes for Carriers

Company: Amazon

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

shipment +-------------+----------+-----------+---------+---------+-------------+-----------+ | shipment_id | order_id | ship_date | carrier | origin | destination | status | +-------------+----------+-----------+---------+---------+-------------+-----------+ | 1001 | 5001 | 2023-09-01| UPS | SEA | NYC | Delivered | | 1002 | 5002 | 2023-09-02| FedEx | LAX | CHI | In-Transit| | 1003 | 5003 | 2023-09-03| USPS | DAL | ATL | Delivered | +-------------+----------+-----------+---------+---------+-------------+-----------+ ​ defect +-----------+-------------+-------------+----------------------+ | defect_id | shipment_id | defect_type | defect_reported_date | +-----------+-------------+-------------+----------------------+ | 1 | 1001 | Damaged | 2023-09-05 | | 2 | 1002 | Lost | 2023-09-06 | | 3 | 1002 | LateDelivery| 2023-09-07 | +-----------+-------------+-------------+----------------------+ ##### Scenario Amazon Logistics team wants to monitor and reduce shipment defects across carriers and shipment lanes. ##### Question Given tables shipment and defect, write SQL to calculate the defect rate (number of defects ÷ number of shipments) for each carrier in the last 30 days. Extend your query to show the week-over-week percentage change in defect rate for each carrier using window functions. Identify the top 3 origin-destination lanes with the highest count of 'Damaged' defects in the past quarter. ##### Hints Join shipment and defect, filter by date, aggregate counts, compute rates, use LAG for WoW change.

Quick Answer: This question evaluates competency in SQL-based data manipulation for a data scientist role, covering joins, aggregations, date-based filtering, metric computation, and use of window functions to derive week-over-week changes.

Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Find recommended friend pairs by shared songs - Amazon (medium)
  • Find recommended friend pairs by shared listening - Amazon (easy)
  • Write SQL window functions for D7 retention - Amazon (medium)
  • Find daily first-order merchants with SQL - Amazon (Medium)
  • Design student–course data models and SQL - Amazon (Medium)