queryDefn.addExpression(expressions[0], BaseTransform.ON_EACH_ROW); queryDefn.addExpression(expressions[1], BaseTransform.AFTER_LAST_ROW);
queryDefn.addResultSetExpression(names[0], expressions[0]); queryDefn.addResultSetExpression(names[1], expressions[1]);
	public void test_sortGroup( ) throws Exception	{		// Test a SQL with duplicate column name (quite common with join data sets)		String testSQL =  "select COUNTRY, AMOUNT from " + getTestTableName( );		((OdaDataSetDesign)this.dataSet).setQueryText( testSQL );				IBaseExpression[] expressions = new IBaseExpression[]{				new ScriptExpression( "row.COUNTRY", 0 ),				new ScriptExpression( "row.AMOUNT", 2 ) };				SortDefinition sortDefn = new SortDefinition();		sortDefn.setExpression( "Total.sum( row.AMOUNT )" );		sortDefn.setSortDirection( sortDefn.SORT_DESC );					GroupDefinition[] groupDefn = new GroupDefinition[]{new GroupDefinition( )};		groupDefn[0].setKeyExpression( "row.COUNTRY" );			groupDefn[0].addSort( sortDefn );						// define a query design						QueryDefinition queryDefn = newReportQuery( );		queryDefn.addExpression(expressions[0], BaseTransform.ON_EACH_ROW);		queryDefn.addExpression(expressions[1], BaseTransform.AFTER_LAST_ROW);					queryDefn.addGroup( groupDefn[0]);									IPreparedQuery preparedQuery = dataEngine.prepare( queryDefn );		IQueryResults queryResults = preparedQuery.execute( null );		IResultIterator resultIt = queryResults.getResultIterator( );		assertTrue( resultIt.next() );		outputQueryResult( executeQuery( queryDefn ), expressions );		checkOutputFile();			}