Grouping

One of the most powerful and time saving features of the SDQL is query grouping. There are two ways to instantiate a query grouping:
  1. implicitly by using a parameter without a restricting condition,
  2. explicitly by using a comma-delimited set of conditions, and

implicit

An implicit grouping is instantiated when a conditional term is not restricted.

To see the average number of three pointers made for each NBA team in 2020 use the SDQL:
Average(three pointers made) @ team and season=2020

Since the team parameter is not restricted to any value, each value occurring in the database is returned.

To see the average number of three pointers made for the Lakers in each season of the database use the SDQL:
Average(three pointers made) @ team=Lakers and season

explicit

An explicit grouping is performed by using a comma-delimited set of values.

To see how NFL teams have done after scoring fewer than 3, 7, 10, and 14 points use the SDQL:
Average(points) @ p:points < 3, 7, 10, 14
Groupings on both sides produce all occurring combinations.
A(points-o:points) as ‘Avg Margin’ @ 0, 10, 14 <= p:points < 10, 14, 21

The implicit and explicit grouping methods can be combined.

To see the average number of three pointers made for each team along with the league average use the SDQL:
Average(three pointers made) @ team,1 and season=2020