document.write("  <div align=left>     <HR> <H3>Summative Methods: Average, Sum, Count, Maximum, Minumum, and Replace.</H3> 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. <p> <b>Season-to-Date Short Cuts</b> <p> SDQL provides short cuts to season-to-date averages and sums: for the team these are <em>tA</em> and <em>tS</em> and for the opponent these are <em>oA</em> and <em>oS</em>. <p> Here are a few examples of season to date summatives using these short cuts: <p> 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: <BR> <em> <a href=http://SportsDataBase.com/nfl.py/query?text=week%20%3E%205%20and%20tA%28passing%20yards%29%20%3E%202%2AoA%28passing%20yards%29>week &gt; 5 and tA(passing yards) &gt; 2*oA(passing yards)</a> </em> <p>  To see how NBA teams do when they have more than 50 wins  while their opponent has fewer than 30 use the SDQL: <BR> <em> <a href=http://SportsDataBase.com/nba.py/query?text=tS%28W%29%20%3E%2050%20and%20oS%28W%29%20%3C%2030>tS(W) &gt; 50 and oS(W) &lt; 30</a> </em> <p>  <p>  In addition to conditional summing, SDQL also allows constraints on the number of games to summed over. To see how MLB teams do when they have scored a total of more than 30 runs  over their past 3 games use the SDQL: <BR> <em> <a href=http://SportsDataBase.com/mlb.py/query?text=tS%28runs%2CN%3D3%29%20%3E%2030>tS(runs,N=3) &gt; 30</a> </em> <p> <b>General Summative Methods</b> <p> The SDQL short cut <em>tA(points)</em> expands out to <em>Average(points@team and season)</em>. 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: <BR> <em> <a href=http://SportsDataBase.com/nba.py/query?text=site%3Dhome%20and%20Average%28points%40team%20and%20season%20and%20site%3Dhome%29%20%3E%3D%20110>site=home and Average(points@team and season and site=home) &gt;= 110</a> </em> <p>  To add the requirement that at least 20 home games have been played use the SDQL: <BR> <em> <a href=http://SportsDataBase.com/nba.py/query?text=site%3Dhome%20and%20Average%28points%40team%20and%20season%20and%20site%3Dhome%29%20%3E%3D%20110%20and%20Count%28team%40team%20and%20season%20and%20site%3Dhome%29%20%3E%3D%2020>site=home and Average(points@team and season and site=home) &gt;= 110 and Count(team@team and season and site=home) &gt;= 20</a> </em> <p>  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:    <BR> <em> <a href=http://SportsDataBase.com/nba.py/query?text=Average%28three%20pointers%20made%40team%20and%20season%29%20%3E%201.5%20%2A%20Average%28three%20pointers%20made%40season%29%20and%20Count%28team%40team%20and%20season%29%20%3E%3D%2030>Average(three pointers made@team and season) &gt; 1.5 * Average(three pointers made@season) and Count(team@team and season) &gt;= 30</a> </em> <p>  To see how teams in the NBA do after averaging at least 130 points  in their last three at home use the SDQL: <BR> <em> <a href=http://SportsDataBase.com/nba.py/query?text=Average%28points%40team%20and%20season%20and%20site%3Dhome%2CN%3D3%29%20%3E%3D%20130>Average(points@team and season and site=home,N=3) &gt;= 130</a> </em> <p> <b>General Summative Methods with Keys</b> <p> The SDQL <em>Average(points@team and season)</em> expands fully out to  <em>Average(points@team and season)[team and season]</em>.  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: <BR> <em> <a href=http://SportsDataBase.com/nfl.py/query?text=week%3D1%20and%20Sum%28L%40team%20and%20season%29%5Bteam%20and%20season-1%5D%20%3E%3D%2010>week=1 and Sum(L@team and season)[team and season-1] &gt;= 10</a> </em> <p> 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: <BR> <em> <a href=http://SportsDataBase.com/nfl.py/query?text=week%3D1%20and%20Sum%28W%40team%20and%20season%20and%20site%3Dhome%20and%20playoffs%3D0%29%5Bteam%20and%20season-1%20and%20site%3Dhome%20and%20playoffs%3D0%5D%20%3D%208>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</a> </em> <p> 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: <BR> <em> <a href=http://SportsDataBase.com/nfl.py/query?text=week%3D1%20and%20Sum%28W%40team%20and%20season%20and%20site%3Dhome%20and%20playoffs%3D0%29%5Bteam%20and%20%5Bseason-1%2Cseason-2%5D%20and%20site%3Dhome%20and%20playoffs%3D0%5D%20%3E%3D%2015>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] &gt;= 15</a> </em> <p> 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: <BR> <em> <a href=http://SportsDataBase.com/nfl.py/query?text=week%3D4%20and%20Sum%28W%40team%20and%20season%29%5Bopponents%20and%20season%5D%20%3D%200>week=4 and Sum(W@team and season)[opponents and season] = 0</a> </em>  <p> 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. <BR> <em> <a href=http://SportsDataBase.com/nfl.py/query?text=Sum%28L%40team%20and%20season%20and%20week%29%5Bteam%20and%20season%20and%20range%281%2CP%3Aweek%29%5D%20%3D%200%20and%20P%3AL%20and%20P%3Aseason%3Dseason>Sum(L@team and season and week)[team and season and range(1,P:week)] = 0 and P:L and P:season=season</a> </em>   <p> 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: <BR> <em> <a href=http://SportsDataBase.com/nba.py/query?text=Minimum%28points%40team%20and%20season%2CN%3D20%29%20%3E%3D%20100>Minimum(points@team and season,N=20) &gt;= 100</a> </em>  <HR>     </div>");
