Query Structures

SDQL query structures range from simple to as simple as possible.

parameters @ conditions

The basic SDQL structure is a comma delimted list of parameters, an @ sign, followed by an and delimited list of conditions. This can be thought of as ‘what I want to see at the conditions under which I want to see it.’

Here are a few examples:

To request the date and points scored by the Colts in the 2016 season, use the SDQL:
date, points @ team=Colts and season=2016
To request the date, points, field goals made and field goals attempted for Bulls home games in 2015, use the SDQL:
date, points, field goals made, field goals attempted @ team=Bulls and site=home and season=2015
To get the date, team, starter, and the number of innings the starter went for all games in the 2017 MLB post season, use the SDQL:
date, team, starter, starter innings pitched @ season=2017 and playoffs=1

All of the sample SDQL queries above are singletons. Here are a few examples of query groupings (see Grouping):

To see the points and assists for each NBA team that played on June 12, 2017, use the SDQL:
points, assists @ team and date=20170612
To see the date and points for each Bulls and each Lakers game in November 2016, along with average points over the whole month of November, use the SDQL:
date, points, A(points) @ team and team in [Bulls,Lakers] and month=10 and season=2016

date and points default to summative type Column which is a list of values; A(points) returns a single value. Because of these mixed request fields, this is called an irregular query. An irregular query is often useful as input to subsequent queries (see Subsequent Queries).

If all of the parameters are summatives (see Summative) then the query result is reduced to a singleton.

To see the average points and average assists for each NBA team in 2016, use the SDQL:
A(points), A(assists) @ team and season=2016

p @ c | p’ @ c’

An SDQL query result is itself an SDQL data table and can be likewise queried (see Subsequent Queries).

To find MLB teams that had a season-long winning percentage of more than 60%, use the SDQL:
tA(W), R((team,season)) @ team and season | $1, $2 @ $1 >.60

conditions

SportsDatabase.com and KillerSports.com both provide defaults when request parameters are not provided.

The default for singleton queries contains summary stats as well as a game listing.
points=100
A grouping query reduces to a table of records (see Grouping).
points=100,120,130,140,150

?arguments

All query structures may end with a ? instantiated and & delimited list of name=value pairs.

To see how NBA teams do after winning their last three same-season matchups, use the SDQL:
P:W and P2:W and P3:W?same_season_P=1

For more examples or SDQL arguments, see Graphics.