The Group-By FeatureOne of the most powerful and time saving features of the SDQL is the group-by feature. This allows you to compare results for several related situations with a single query. There are two ways in which to instantiate a group-by: implicitly by using a parameter without a condition and explicitly by using a comma delimited set of conditions.
To see the average number of three pointers made for each NBA team in the 2007 season use the SDQL:
Average(three pointers made)@team and season=2007
Note that since the team parameter is not set to any value, each value occuring in the database is returned.
An explicit group-by is performed by using a comma delimited set of values.
To see how NFL teams do after scoring fewer than 3, 7, 10, and 14 points use the SDQL:
p:points < 3, 7, 10, 14
SDQL also allows ranges of values to be groups as per:
0, 10, 14 <= p:points < 10, 14, 21
The implicit and explicit group-by methods can be combined.
To add the League results to the above query for average number of three pointers made use the SDQL:
Average(three pointers made)@team,1 and season=2007