Nonstop Database, HiRDB Version 9 UAP Development Guide

[Contents][Index][Back][Next]

2.9.1 Data grouping

If a value is repeated in a specified column, all the items with that value can be grouped as a single item in the retrieval results. The GROUP BY clause performs this grouping. The AVG, SUM, MAX, MIN, and COUNT set functions, respectively, can be used to obtain the average value, total value, maximum value, minimum value, and rows count of each group.

The following figure shows, as an example of data grouping, the procedure for grouping sets of product codes in the ORDER1 table and then extracting the total quantity ordered for each group.

Figure 2-35 Data grouping example

[Figure]