private boolean useAggregateFunction(String fields){
  String fieldsUpper=fields.toUpperCase();
  int size=fieldsUpper.length();
  StringBuffer buffer=new StringBuffer();
  String token=null;
  for (int i=0; i < size; i++) {
    char ch=fieldsUpper.charAt(i);
    if (Character.isWhitespace(ch)) {
      if (buffer.length() > 0) {
        token=buffer.toString();
        buffer=new StringBuffer();
      }
    }
 else {
      if (isOperator(ch)) {
        if (buffer.length() > 0) {
          token=buffer.toString();
          buffer=new StringBuffer();
        }
 else {
          token=null;
        }
        if (ch == '(' && token != null) {
          if (token.equals("SUM") || token.equals("MAX") || token.equals("MIN")|| token.equals("COUNT")|| token.equals("AVG")) {
            return true;
          }
        }
      }
 else       buffer.append(ch);
    }
  }
  return false;
}

private boolean useAggregateFunction ( String fields ) { String fieldsUpper = fields . toUpperCase ( ) ; int size = fieldsUpper . length ( ) ; StringBuffer buffer = new StringBuffer ( ) ; String token = null ; for ( int i = 0 ; i < size ; i ++ ) { char ch = fieldsUpper . charAt ( i ) ; if ( Character . isWhitespace ( ch ) ) { if ( buffer . length ( ) > 0 ) { token = buffer . toString ( ) ; buffer = new StringBuffer ( ) ; } } else { if ( isOperator ( ch ) ) { if ( buffer . length ( ) > 0 ) { token = buffer . toString ( ) ; buffer = new StringBuffer ( ) ; } else { token = null ; } if ( ch == '(' && token != null ) { if ( token . equals ( "SUM" ) || token . equals ( "MAX" ) || token . equals ( "MIN" ) || token . equals ( "COUNT" ) || token . equals ( "AVG" ) ) { return true ; } } } else buffer . append ( ch ) ; } } return false ; }
check if one of the field is using standard sql aggregate function
