PP
Predictive Playbook Database
Query User's Guide — how to write queries that work

Query User's Guide

How to write queries that work the first time. Every example below is a real query you can paste into the NFL or NCAAF query tool — click any example to copy it. For the full list of fields and macros, see the NFL and NCAAF references.

1. The basics 2. Season totals & averages 3. "Entering this game" 4. Rolling last-N games 5. Counting wins, covers & more 6. The opponent 7. Game-by-game lookups 8. Recipes 9. Common mistakes

1. The basics

Every row in the database is one team in one game. A query is a list of conditions a row must meet. Join them with and / or (and binds tighter than or), flip one with not, and group with parentheses. The tool then shows how those teams did against the spread, straight up, and over/under.

line>=3 and line<=9.5 and H
Home teams getting between 3 and 9.5 points. The chained form 9.5>=line>=3 means the same thing.

2. Season totals & averages

A season call looks at a team's whole season and boils it down to one number. It has three parts: the letter t (this team), an optional marker for which season, and what to calculate.

CalculateLetterMeaning
TotalSSum — or a count when you give it a condition like W
AverageAAverage — or the fraction (0–1) of games when you give it a condition
HighestMAXThe biggest single value
LowestMINThe smallest single value
MarkerWhich gamesExample
(none)The entire current season — including this game and games after ittA(points)
bThis season, but only games before this onetbA(points)
pLast seasontpA(points)
ppTwo seasons backtppA(points)
tpA(points)>=27
Teams that averaged 27+ points per game last season.
tpS(W)>=11
Teams that won 11 or more games last season. (tpA(W)*100>=65 asks for a 65%+ win rate instead.)
tpMAX(wins)>=6
Teams whose win total reached 6+ last season. Use MAX (not S) on running-tally columns like wins — adding up a counter overcounts.
Count or fraction? S gives a count: tS(W)>=3 means 3 or more wins. A gives a fraction from 0 to 1: tA(W)>=0.6 means a 60% win rate. Writing tA(W)>=6 can never match.

3. "Entering this game" — the b marker

A plain tS(W) counts the whole season, including games that hadn't happened yet when this row's game was played. For a betting system you almost always want what the team knew going into the game. Add b:

tbS(W)=0
Winless entering this game. (Plain tS(W)=0 would mean winless the entire season — hindsight.)
tbA(points)>=28 and tbA(o:points)<=17
Scoring 28+ a game and allowing under 17 a game, counting only games before this one.

The first game of a season has no earlier games, so b conditions never match it. That's intended — there's nothing to measure yet.

4. Rolling last-N games NEW

Add ,N=k inside any season call to look at only the last k games — "how is this team playing lately." The window is the k games played before the current game, so it's safe to use as a pregame filter.

tA(points,N=4)>=28
Averaging 28+ points over its last 4 games.
tA(o:points,N=3)<=14
Allowed 14 or fewer points a game over the last 3 games (o: reaches the opponent's score in each of those games).
tS(rushingyards,N=3)>=600 tMAX(points,N=5)>=40 tMIN(passingyards,N=3)>=200

5. Counting wins, covers & more

Put a whole condition inside S or A to count or take the fraction of games that meet it.

tS(W,N=3)>=2
Won at least 2 of its last 3 games.
tA(W,N=5)>=0.6
Won 60%+ of its last 5 games. Add *100 to use percentages: tA(W,N=5)*100>=60.
tS(atsmargin>0,N=4)>=3
Covered the spread in at least 3 of its last 4.
tpA(atsmargin>0)*100>=60
Covered at least 60% of its games last season.
tbS(H)>=2
Already played 2+ home games this season.

Ready-made macros cover the common ones: SUW, SUL, ATSW, ATSL, SUPCT, ATSPCT and more, all "entering this game."

6. The opponent

Put o in front of a season call to measure today's opponent instead of this team: oA(points) is what the opponent scores per game. Use o: inside the parentheses to look at what a team's opponents did: tA(o:points) is what this team allows.

tbA(points)>=27 and oA(o:points)>=26
A team scoring 27+ a game facing an opponent that allows 26+ a game.
oA(points,N=3)<=17
The opponent averaged 17 or fewer points over its last 3 games.
tpS(W)>opS(W)
This team won more games last season than today's opponent did.

7. Game-by-game lookups

Prefixes with a colon reach a specific other game instead of a season: p: the previous game, pp: two games back (or p3: for three), n: the next game, o: the opponent in this same game, op: the opponent's previous game, P: the last meeting between these two teams.

p:L and H and line>=-3
Home team that lost its last game.
points>p:points
Scored more than it did in its previous game.
STREAKPREV(2,L)
Lost its last two games of last season (correct from any week).

Prefix lookups follow the team's whole schedule, so in Week 1 p: means last season's final game. Rolling windows and tb calls stay inside the current season.

8. Recipes

Hot offense, bad defense matchup

tA(points,N=4)>=28 and oA(o:points,N=4)>=26

Bounce-back spot

p:L and tbA(W)>=0.5 and line<=7

Cold team getting points

tS(W,N=4)=0 and line>=3

Last season's best defenses starting fast

tpA(o:points)<=18 and tbA(o:points)<=17

Rested, in-form favorite

line<=-3 and tA(atsmargin,N=3)>0

9. Common mistakes

Using tS(W)=0 to mean "winless so far." Without b it counts the whole season, including later games. Use tbS(W)=0.
Summing a running total. Columns like wins already accumulate through the season. Use tpMAX(wins), not tpS(wins).
Mixing up count and fraction. S counts (>=3); A is 0–1 (>=0.6) or 0–100 with *100.
Expecting a window to span seasons. tA(points,N=4) in Week 2 averages only the one earlier game, and Week 1 never matches. For last season's tail use tpA(points,N=4).
Still stuck? The Learn section walks through a full query start to finish, and the Field/Query Reference lists every shortcut and macro. Or ask the natural-language box on the query page.
Copied