.. _basic-anchor: 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 :ref:`group-anchor`): 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 :ref:`subsequent-anchor`). If all of the parameters are *summatives* (see :ref:`summative-anchor`) 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 :ref:`subsequent-anchor`). To find MLB teams that had a season-long winning percentage of more than 60%, use the SDQL: A(W), R((team,season)) @ team and season | $1, $2 @ $1 >.60