.. _subsequent-anchor: Subsequent Queries ================== A simple SDQL query consists of stepping through each half-game in the database from first game to last. Sometimes a single pass through the data is not enough. In this case a subsequent query is used. This is analogous to SQL's *HAVING* clause and is instantiated with the *pipe* symbol '|'. The most common use of subsequent query is to check which query groups are active on a given date. As a simple example, say we are interested in how each NBA team does when averaging 10-plus points more than its opponent. The base query for this situation is: A(W) @ tA(points) > 10+oA(points) and team This SDQL query returns the winning percentage of each team in this situation (see :ref:`group-anchor`). Now, say we want to know which teams have this SDQL trend active for a given day. For this example, let's just take January 12, 2017. To see the winning percentage and team name for all teams that qualify for this SDQL trend on January 12, 2017, use the SDQL: date,R(team),A(W) @ tA(points) > 10+oA(points) and team | $2,$3 @ 20170112 in $1 Parameters in the subsequent query are identified by their index with the '$' prefix. That is, 'date' is the first request parameter and is referenced in the subsequent query with '$1'. The subsequent query parameters can also be referenced by name. The above query is functionally the same as: date as Dates,R(team) as Team,A(100*(W)) as 'Wpct'@ tA(points) > 10+oA(points) and team|Team,Wpct @ 20170112 in Dates