Pregunta de entrevista de Chubb

How will u write this query in SQL?