code: public Query execute(PageContext pc, SQL sql, Selects selects, int maxrows) throws PageException {
  	Column[] orders = selects.getOrderbys();
  	Select[] arrSelects = selects.getSelects();
  
  	QueryImpl target = new QueryImpl(new Collection.Key[0], 0, "query", sql);
  
  	for (int i = 0; i < arrSelects.length; i++) {
  	    arrSelects[i].getFroms();
  	    Column[] froms = arrSelects[i].getFroms();
  	    if (froms.length > 1) throw new DatabaseException("can only work with single tables yet", null, sql, null);
  	    executeSingle(pc, arrSelects[i], getSingleTable(pc, froms[0]), target, arrSelects.length > 1 ? -1 : maxrows, sql, orders.length > 0);
  	}
  
  	// Order By
  	if (orders.length > 0) {
  	    order(target, orders);
  	    if (maxrows > -1) target.cutRowsTo(maxrows);
  	}
  	// Distinct
  	if (selects.isDistinct()) {
  	    order(target, selects.getDistincts()); // order to filter
  	    // print.e(selects.getDistincts());
  	    Key[] _keys = target.getColumnNames();
  	    QueryColumn[] columns = new QueryColumn[_keys.length];
  	    for (int i = 0; i < columns.length; i++) {
  		columns[i] = target.getColumn(_keys[i]);
  	    }
  
  	    int i;
  	    Object l, r;
  	    outer: for (int row = target.getRecordcount(); row > 1; row--) {
  		for (i = 0; i < columns.length; i++) {
  		    l = columns[i].get(row, null);
  		    r = columns[i].get(row - 1, null);
  		    if (l == null || r == null) {
  			if (l != r) continue outer;
  		    }
  		    else if (!Operator.equals(l, r, true)) continue outer;
  		}
  		target.removeRow(row);
  	    }
  	}
  	order(target, orders);
  
  	return target;
      }
docs: execute a SQL Statement against CFML Scopes