Pergunta de entrevista da empresa IBM

sql question writing a method based on table