Using a GROUP BY clause
The query in the following example selects all rows in the STAFF table of the SAMPLE database and groups them by job type. Evaluate the code using the Inspect command:
"GROUP BY Clause"
| querySpec result resultCollection connection |
resultCollection := OrderedCollection new.
connection := AbtDbmSystem activeDatabaseConnectionWithAlias: 'SampleConSpec'.
querySpec := (AbtQuerySpec new)
statement: 'SELECT STAFF.NAME, STAFF.ID, STAFF.DEPT,
STAFF.JOB, STAFF.YEARS, STAFF.SALARY,
STAFF.COMM FROM STAFF GROUP BY STAFF.JOB,
STAFF.DEPT, STAFF.NAME, STAFF.ID, STAFF.YEARS,
STAFF.SALARY, STAFF.COMM'.
result := connection resultTableFromQuerySpec: querySpec.
result do: [:eachRow | resultCollection add: (eachRow asString)].
^resultCollection.
 
Last modified date: 01/29/2015