Amazon interview question

Medium sql question for live coding