FINEXUS Group interview question

(Test) Logical thinking, coding, SQL