FastPrepCombine Winner and Loser Names
Problems/Combine Winner and Loser Names

Combine Winner and Loser Names

Amazon logoAmazon● EasyINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionConstraints

Problem statement

Source note: In an Amazon intern onsite SQL round, the candidate got two small tables, one for winners and one for losers, each with an ID and a name. The task was to put all the names into one result, and the interviewer also wanted both UNION and UNION ALL tried and the difference explained.

The report does not say whether a name that shows up more than once should be kept once or every time, and it gives no sample rows. Here, each distinct name is returned once, in any order. The UNION ALL comparison is a follow-up covered in the editorial and is not checked.

Our version is about 90% the same as the reported question.

The winner table and the loser table each have one row per person: an id and a name.

Write a query that puts the names from both tables into one output column called name. Show each name only once, even if it is in both tables or appears more than once in the same table.

Return the rows in any order.

Interview follow-up

Write the query once with UNION and once with UNION ALL, and explain how the two results differ. Only the version above, with each name once, is checked.

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.

winner

One row per winner.

ColumnTypeNullableDescription
idPKIntegerNo—
nameTextNo—

loser

One row per loser.

ColumnTypeNullableDescription
idPKIntegerNo—
nameTextNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
nameTextNo—

Row order: any order is accepted. Numeric tolerance: 0.

Constraints

  • Each table has from 0 to 10^5 rows.
  • id is unique within each table, and 1 <= id <= 10^9. The same id in the two tables does not mean the same person.
  • No column is NULL.
  • Each name has 1 to 20 English letters: one uppercase letter followed by lowercase letters.

More Amazon Onsite Interview questions

  • Number of IslandsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Cheapest Flights Within K StopsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Dungeon GameONSITE INTERVIEW · Seen Nov 2026
  • Integer BreakONSITE INTERVIEW · Seen Nov 2026
  • LFU CacheONSITE INTERVIEW · Seen Nov 2026
  • LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Count Adjacent Symbol Pairs for BPEONSITE INTERVIEW · Seen Nov 2026
  • First Non-Repeating CharacterOA · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Delete Duplicate Employee RecordsInfosys · ONSITE INTERVIEWInfosys interview questions
  • Records Created or Updated in a Time WindowPelatro · ONSITE INTERVIEW
  • Top Ten Employee SalariesSolytics Partners · ONSITE INTERVIEW
  • Latest New JobSphere · ONSITE INTERVIEW
  • Employees Whose Manager Left the CompanyZS · ONSITE INTERVIEWZS interview questions
  • Employees Above Average SalaryJP Morgan Chase · ONSITE INTERVIEWJP Morgan Chase interview questions
  • Retrieve Every Student RecordLSEG · ONSITE INTERVIEWLSEG interview questions
  • Conditionally Insert or Update RecordsKlaviyo · ONSITE INTERVIEWKlaviyo interview questions
  • Employees with Matching DepartmentsAMD · ONSITE INTERVIEWAMD interview questions
  • New-User Devices That Opened an AppMicrosoft · ONSITE INTERVIEWMicrosoft interview questions

Interview reports that mention this question

  • Amazon BIE Intern SQL and Interview Questions: 17 Experiences

Amazon interview experiences

  • Amazon SWE OA with AI Coding: 1 Experience
  • Amazon SWE Intern Phone Screen Interview Experience: 1 Experience
  • Amazon New Grad SDE I OA and Virtual Onsite: 1 Experience
  • Amazon Experienced SWE AI-Assisted Debugging OA: 1 Experience
  • Amazon SDE II (L5) Interview Questions: 5 Experiences
See Amazon hiring insights