Amazon Interview Question

sql hard level leetcode question