Identify SQL Joins and Correct Query Errors
Company: Amazon
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: Medium
Interview Round: Onsite
Winner
+----+-------+
| ID | Name |
+----+-------+
| 1 | Alice |
| 2 | Bob |
| 3 | Carol |
+----+-------+
Loser
+----+-------+
| ID | Name |
+----+-------+
| 4 | Dave |
| 5 | Erin |
| 6 | Frank |
+----+-------+
##### Scenario
Database fundamentals and querying names from separate winner and loser tables
##### Question
What is a primary key and why is it important in relational databases? List the different types of SQL joins you know and explain when you would use each. The following query has errors. Identify and correct them:
select name MONTH(timestamp)
FROM table
WHEREMONTH(timestamp)>2010 Given tables Winner(ID, Name) and Loser(ID, Name), write a query that outputs all names in a single column. Use both UNION and UNION ALL, and explain the difference between the two operators.
##### Hints
Review relational keys, join semantics, date functions, UNION vs UNION ALL, and standard SQL syntax corrections.
Quick Answer: This question evaluates relational database fundamentals including the role of primary keys, SQL join types, set operations (UNION vs UNION ALL), date functions, and the ability to debug and correct SQL query syntax, reflecting both conceptual understanding and practical query-writing skills.