SQLSQL
#49

Dual Metric Aggregation with UNION ALL in SQL

MediumAmazon
Interview Question #49
Asked at Amazon

Given `movies`, `users`, and `movie_rating`, write a query to find: 1) the user who has rated the greatest number of movies (tie-break by user name alphabetical); 2) the movie with the highest average rating in February 2026 (tie-break by title).

Input Table: movie_rating
3 rows preview
movie_iduser_idratingcreated_at
1132026-02-12
2142026-02-15
1252026-02-14
Expected Output Structure2 rows
results
User One
Movie One
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

SQLPostgreSQL 15
Ready to execute

Click "Run Query" or press Ctrl + Enter to test your query.

Output will be verified against the test dataset.

Chat with us