Elavon interview question

SQL question (moderate difficulty)