S p o r t s D a t a B a s e . c o m
a sports data query language (SDQL ©) consultancy

Permission is given to quote trends found on SportsDataBase.com provided that a reference and a link to SportsDataBase.com is provided. E.g.: Trend found on SportsDataBase.com


Information you need to win
TOC  |  Introduction  |  Basics  |  Prefixes  |  Parameters  |  Group-By  |  Summative  |  Links  |  e-mail

Summative Methods: Average, Sum, Count, Maximum, Minumum, and Replace.

There are three levels of summative methods which increase in power and complexity: season-to-date short cuts, general summative methods, and keyed summative methods. Each is explained below.

Season-to-Date Short Cuts

SDQL provides short cuts to season-to-date averages and sums: for the team these are tA and tS and for the opponent these are oA and oS.

Here are a few examples of season to date summatives using these short cuts:

To see how NFL teams do after week 5 when they average more than twice as many passing yards as their opponent use the SDQL:
week > 5 and tA(passing yards) > 2*oA(passing yards)

To see how NBA teams do when they have more than 50 wins while their opponent has fewer than 30 use the SDQL:
tS(W) > 50 and oS(W) < 30

General Summative Methods

The SDQL short cut tA(points) expands out to Average(points@team and season). This is read, "The average points for each team and season". The text to the right of the '@' sign defines the conditions under which the average is taken and can be any valid SDQL condition. For example, to query on NBA teams at home with a home court season-to-date average score of 110 points or more use the SDQL:
site=home and Average(points@team and season and site=home) >= 110

To add the requirement that at least 20 home games have been played use the SDQL:
site=home and Average(points@team and season and site=home) >= 110 and Count(team@team and season and site=home) >= 20

The general summative methods also allow comparison with league averages. To see how teams do when they average 50% more three pointers than the league average and requiring that the team has played at least 30 games use the SDQL:
Average(three pointers made@team and season) > 1.5 * Average(three pointers made@season) and Count(team@team and season) >= 30

In addition to conditional averaging, SDQL also allows constraints on the number of games. To see how teams in the NBA do after averaging at least 130 points in their last three at home use the SDQL:
Average(points@team and season and site=home,N=3) >= 130

General Summative Methods with Keys

The SDQL Average(points@team and season) expands fully out to Average(points@team and season)[team and season]. This is read "Average points for each team and season evaluated at that team and season". The most common use of this long form is to check for results from previous seasons. For example, to see how NFL teams do in week 1 after losing 10 or more games in the previous season use the SDQL:
week=1 and Sum(L@team and season)[team and season-1] >= 10

Note that whatever conditions are to the right of the `@` sign must appear in the same order within the square brackets. To see how teams do in week 1 after winning 8 games at home during the previous regular season use the SDQL:
week=1 and Sum(W@team and season and site=home and playoffs=0)[team and season-1 and site=home and playoffs=0] = 8

If one of the terms in the square bracket is a list of values then the summative method is taken over that list. To see how teams do in week 1 after winning at least 15 home games during the previous two regular seasons use the SDQL:
week=1 and Sum(W@team and season and site=home and playoffs=0)[team and [season-1,season-2] and site=home and playoffs=0] >= 15

The use of lists inside of the square bracket is also useful for strength-of-opponent queries. To see how NFL teams do in week 4 after having faced opponents who are still winless use the SDQL:
week=4 and Sum(W@team and season)[opponents and season] = 0

Note here how the Python method `range` is used to take the Sum over weeks to isolate games where a team is playing an opponent they lost to in their previous meeting to suffer their first defeat of the season.
Sum(L@team and season and week)[team and season and range(1,P:week)] = 0 and P:L and P:season=season

The Maximum and Minumum methods are useful for checking a team's recent performance. To see how NBA teams do after scoring at least 100 points 20 games in a row use the SDQL:
Minimum(points@team and season,N=20) >= 100


TOC  |  Introduction  |  Basics  |  Prefixes  |  Parameters  |  Group-By  |  Summative  |  Links  |  e-mail
e-mail links:   Content@SportsDataBase.com    Support@SportsDataBase.com   
Google Group Discussion Forum