The following coding example use ranking to return the 5 tallest pupils in the class.
/** * * A simple method creates a ranked result set for a relational table.* @param list of data items in an information map.
* @param input data selection
* @return modified data selection containing the result
*
* @throws Exception
*/private com.sas.iquery.metadata.business.DataSelection RankRelationalTableDisplay(java.util.List dsDataItems, com.sas.iquery.metadata.business.DataSelection query) throws Exception
{
//apply ranking step to height dataItem
com.sas.iquery.metadata.business.step.relational.DataItemRankFilter top5Step = new com.sas.iquery.metadata.business.step.relational.DataItemRankFilter(com.sas.iquery.metadata.business.step.relational.DataItemRankFilter.TOP, 5, true);
for(int i = 0; i < dsDataItems.size(); i++)
{ com.sas.iquery.metadata.business.DataItem tdi = (com.sas.iquery.metadata.business.DataItem)dsDataItems.get(i);
String label = tdi.getLabel();
// Get column to be ranked and apply step
if ( label.equalsIgnoreCase("Height") )
{ tdi.addStep(top5Step);
}
//Assign Column to all dataitems and add to dataselection.
query.addResultItem(tdi, com.sas.iquery.metadata.business.Role.COLUMN);
}
// Get data selection
return query;
}