Management Solutions interview question

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