The type of query is SELECT (into WorktableN).
Queries using a group by clause first put qualifying results into a worktable. The data is grouped as the table is generated. A second step returns the grouped rows.
The following example returns a list of all cities and indicates the number of authors that live in each city. The query plan shows the two steps: the first step selects the rows into a worktable, and the second step retrieves the grouped rows from the worktable:
select city, total_authors = count(*) from authors group by city
QUERY PLAN FOR STATEMENT 1 (at line 1). STEP 1 The type of query is SELECT (into Worktable1). GROUP BY Evaluate Grouped COUNT AGGREGATE. FROM TABLE authors Nested iteration. Table Scan. Forward scan. Positioning at start of table. Using I/O Size 16 Kbytes for data pages. With LRU Buffer Replacement Strategy for data pages. TO TABLE Worktable1. STEP 2 The type of query is SELECT. FROM TABLE Worktable1. Nested iteration. Table Scan. Forward scan. Positioning at start of table. Using I/O Size 16 Kbytes for data pages. With MRU Buffer Replacement Strategy for data pages.