# Relational usage use case

This example uses two items as categories and two as measures with different aggregations.
The result is that the measures are aggregated based on the values of the categories, using their aggregation function (SUM and AVG in this case).

    		DataSelection query = ...;

    		//get the data items used in the query:
    		List resultItems = query.getResultItems();
    		DataItem sex = (DataItem) resultItems.get(0);
    		DataItem age = (DataItem) resultItems.get(1);
    		DataItem height = (DataItem) resultItems.get(2);
    		DataItem weight = (DataItem) resultItems.get(3);

    		//make sex and age categories:
    		sex.setUsage(DataItemActionType.USAGE_CATEGORY);
    		age.setUsage(DataItemActionType.USAGE_CATEGORY);
    		//make height and weight aggregate measures:
    		height.setUsage(DataItemActionType.USAGE_AGGREGATE);
    		weight.setUsage(DataItemActionType.USAGE_AGGREGATE);

    		//get the SUM and AVG functions as known by the server:
    		ServerProperties serverProperties = query.getServerProperties();
    		Function sumFunction = serverProperties.getFunctionByNameID(FunctionNameID.SUM);
    		Function avgFunction = serverProperties.getFunctionByNameID(FunctionNameID.AVG);

    		//set the aggregations to use for the two measures:
    		height.setAggregationType(sumFunction);
    		weight.setAggregationType(avgFunction);

    		//execute the query

The result of this query is: