This example uses ranking to return only the 5 tallest pupils:
DataSelection query = buildClassroomDataSelection(); //get all the result items List resultItems = query.getResultItems(); //we asked for height to be the fourth result item/column, so we won't check: DataItem height = (DataItem) resultItems.get(3); //create a ranking step filter which returns the top 5 heights: DataItemRankFilter top5Step = new DataItemRankFilter(DataItemRankFilter.TOP, 5, true); height.addStep(top5Step); //execute the query
The result is: