#### 7.67.4 GROUP_BY Examples of Expandable Groups

Example 1: Groups assembled from other groups:

GROUP_BY  NAME(#XG_GRP1) FIELDS(#A #B #C #D)

GROUP_BY  NAME(#XG_GRP2) FIELDS(#E #F #G #H)

GROUP_BY  NAME(#XG_GRP3) FIELDS(#XG_GRP1 #XG_GRP2)

is equivalent to writing:

GROUP_BY  NAME(#XG_GRP3) FIELDS(#A #B #C #D #E #F #G #H)

Example 2: Groups assembled from other groups which share common fields:

GROUP_BY  NAME(#XG_GRP1) FIELDS(#A #B #C #D)

GROUP_BY  NAME(#XG_GRP2) FIELDS(#C #D #E #F)

GROUP_BY  NAME(#XG_GRP3) FIELDS(#XG_GRP1 #XG_GRP2)

is equivalent to writing:

GROUP_BY  NAME(#XG_GRP3) FIELDS(#A #B #C #D #E #F)

When the field list is expanded, the fields from group #XG_GRP2 which are already in the field list are not added again.

Example 3: Mixing expandable groups and individual fields in the field list:

GROUP_BY  NAME(#XG_GRP1) FIELDS(#A #B #C)

GROUP_BY  NAME(#XG_GRP2) FIELDS(#E #F #G)

GROUP_BY  NAME(#XG_GRP3) FIELDS(#XG_GRP1 #D #XG_GRP2 #H)

is equivalent to writing:

GROUP_BY  NAME(#XG_GRP3) FIELDS(#A #B #C #D #E #F #G #H)

Example 4: Using *EXCLUDING and *INCLUDING special values in the field list:

GROUP_BY  NAME(#XG_GRP1) FIELDS(#A #B #C #D #E)

GROUP_BY  NAME(#XG_GRP2) FIELDS(#F #G #H #I #J)

GROUP_BY  NAME(#XG_GRP3) FIELDS(#XG_GRP1 *EXCLUDING #D #E *INCLUDING #XG_GRP2 *EXCLUDING #J)

is equivalent to writing:

GROUP_BY  NAME(#XG_GRP3) FIELDS(#A #B #C #F #G #H #I)