PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches

Quick Overview

This question evaluates competency in data manipulation, deduplication of symmetric relationships, and handling unordered pairs within relational or tabular datasets using SQL or Python/Pandas.

  • Medium
  • Amazon
  • Data Manipulation (SQL/Python)
  • Business Intelligence Engineer

Identify Unique Unordered City Pairs in Flight Log

Company: Amazon

Role: Business Intelligence Engineer

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Onsite

FLIGHTS +----------------+---------------+ | departure_city | arrival_city | +----------------+---------------+ | NYC | LAX | | LAX | NYC | | ORD | ATL | +----------------+---------------+ ##### Scenario You work with an airline flight log. Each row records a flight’s origin and destination city. Management wants to see all distinct city pairs regardless of flight direction (NYC–LAX is the same as LAX–NYC). ##### Question Write a SQL query (or equivalent Python/Pandas snippet) that returns the unique unordered city pairs from the FLIGHTS table, treating (A,B) and (B,A) as the same route combination. ##### Hints Normalize the order of the two cities—e.g., use LEAST/GREATEST or sort values—then GROUP BY the normalized pair.

Quick Answer: This question evaluates competency in data manipulation, deduplication of symmetric relationships, and handling unordered pairs within relational or tabular datasets using SQL or Python/Pandas.

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)