Using Transact-SQL queries with COMPUTE clause

jConnect for JDBC supports Transact-SQL queries that include a COMPUTE clause. A COMPUTE clause allows you to display detail and summary results in one select statement. The summary row appears following the detail rows of a specific group. For example:

select type, price, advance
   from titles
   order by type
   compute sum(price), sum(advance) by type
type          price      advance
------------  ---------  ----------
UNDECIDED     NULL       NULL

Compute Result:
------------------------ ------------------------
NULL                     NULL

type          price      advance
------------  ---------  ----------
business      2.99       10,125.00
business      11.95      5,000.00

business      19.99      5,000.00
business      19.99      5,000.00

Compute Result:
------------------------ ------------------------
54.92                    25,125.00

...
...

(24 rows affected)

When jConnect executes a select statement that includes a COMPUTE clause, jConnect returns multiple result sets to the client, the number of result sets depends on the number of unique groupings available. Each group contains one result set for the detail rows and one result set for the summary. The client must process all result sets to fully process the rows returned; if it does not, only the detail rows of the first group of data are included in the first result set returned.

For more information about the COMPUTE clause, see the Adaptive Server Enterprise Transact-SQL Users Guide. For more information about processing multiple result sets, see the JDBC API documentation found on the Sun Microsystems Web site.