Starbucks interview question

It was a Leetcode medium SQL question.