Pergunta de entrevista da empresa Management Solutions

How do you query this in SQL? how do you return this type in Java? etc...