Pregunta de entrevista de IBM

sql question writing a method based on table