Pregunta de entrevista de Sigmoid

SQL query based problem mostly