Group By Query

The $QueryGroup function can be used to create a value group based on the database query. There are two versions of the function. The first uses the default connection. The second allows the user to specify custom connection (predefined ODBC data source name). Both have the following parameters:

  1. Group No. Positive Integer.
  2. Query text. Additional quotation by '(' and ')' is required for the query that contains ','. The function (like $Pattern) call is acceptable as well.
  3. (optional) Use data from the table sequentially. 0 or 1, default is 0 (false). The first row will be used after the last if necessary.

The second version has three additional parameters:

  1. Predefined Data Source Name. String. Use ODBC Administrator* to prepare or manage it.
  2. (optional) Login. String, default is empty.
  3. (optional) Password. String, default is empty.

* you should use 32 or 64 bit version of the administrator depend on application version.

Note: function returns NULL value for an empty recordset

Examples

$QueryGroup(1,(select AgentName,Code from Contracts)) - specifies query as data source and uses 'AgentName' column.
$Group(1,2) - refers to the second column 'Code'.
$QueryGroup(1,(select AgentName,Code from Contracts),0,MyDb,UserName,Password) - uses "MyDb" ODBC data source with specified user name and password.