UBS interview question

how do you apply group by Claus using Java