SQL for Lottery Analysis series
- Part 1: Count how often each number is drawn
- Part 2: Find "overdue" numbers with window functions
- Part 3: Measure jackpot rollover streaks (you are here)
- Part 4: Same number, same day, different states
- Part 5: Test it all: why none of it predicts a draw
Free practice data: SQLite database · Powerball CSV · Pick 3/Pick 4 CSV
When nobody wins the Powerball jackpot, it rolls over and grows. When someone wins, it resets to the starting amount. A stretch of draws between two wins is a jackpot run, and finding runs in a table is a classic SQL puzzle known as "gaps and islands." This part solves it with the jackpot column in the sample database, then checks the answer against official records, which turns up a lesson about trusting data. For how rollovers work, see how jackpot rollovers work.
Step 1: Compare each draw with the one before
LAG(jackpot), the window function from Part 2, puts the previous draw's jackpot next to the current one. Here are the draws around Christmas 2025:
SELECT draw_date,
jackpot,
LAG(jackpot) OVER (ORDER BY draw_date) AS previous_jackpot
FROM powerball_draws
WHERE draw_date BETWEEN '2025-12-17' AND '2025-12-31';Result:
| draw_date | jackpot | previous_jackpot |
|---|---|---|
| 2025-12-17 | 1266700000 | NULL |
| 2025-12-20 | 1434600000 | 1266700000 |
| 2025-12-22 | 1586600000 | 1434600000 |
| 2025-12-24 | 1816800000 | 1586600000 |
| 2025-12-27 | 21100000 | 1816800000 |
| 2025-12-29 | 34300000 | 21100000 |
| 2025-12-31 | 53400000 | 34300000 |
The jackpot climbed to $1,816,800,000 on December 24, then the next draw's jackpot was $21 million (Powerball.com). That drop is the signature of a win. Powerball confirms a single ticket sold in Arkansas won a $1.817 billion jackpot in the December 24, 2025 drawing (Powerball.com). The first row shows NULL because LAG only looks inside the rows the query returns, and the window starts there.
Step 2: List the wins
If the jackpot is lower than the draw before, the draw before was won. That rule finds the wins. Here it is for 2026, up to Powerball's November 5 announcement of the New Jersey win:
WITH flagged AS (
SELECT draw_date,
jackpot,
LAG(draw_date) OVER (ORDER BY draw_date) AS previous_draw,
LAG(jackpot) OVER (ORDER BY draw_date) AS previous_jackpot
FROM powerball_draws
)
SELECT previous_draw AS draw_won,
previous_jackpot AS jackpot_won,
draw_date AS next_draw,
jackpot AS new_jackpot
FROM flagged
WHERE jackpot < previous_jackpot
AND draw_date BETWEEN '2026-01-01' AND '2026-11-07'
ORDER BY draw_date;Result:
| draw_won | jackpot_won | next_draw | new_jackpot |
|---|---|---|---|
| 2026-01-21 | 209300000 | 2026-01-24 | 20000000 |
| 2026-03-02 | 250800000 | 2026-03-04 | 20000000 |
| 2026-04-06 | 231000000 | 2026-04-08 | 20000000 |
| 2026-04-29 | 143000000 | 2026-05-02 | 20000000 |
| 2026-08-12 | 1040000000 | 2026-08-15 | 20000000 |
| 2026-11-04 | 847000000 | 2026-11-07 | 20000000 |
Powerball's own list of 2026 jackpot wins in that announcement is January 21, March 2, April 6, April 29, May 2, August 12 and November 4 (Powerball.com). The query found six of the seven. The one it missed is a useful lesson.
On April 29, 2026, tickets in Indiana and Kansas won $143 million. Then on May 2, the very next drawing, tickets in Florida and Texas split the $20 million starting jackpot (Powerball.com). The jackpot went from $20 million to $20 million, so it never dropped, and the "lower than before" rule couldn't see the second win. Every query rests on an assumption, and the way to find where it breaks is to check the results against an outside source.
The amounts match Powerball's announcements too: $1.040 billion in Illinois on August 12 (Powerball.com) and $847 million in New Jersey on November 4 (Powerball.com). For won draws, this table holds the amount the lottery announced, which can be higher than the estimate advertised before the draw.
Step 3: Number the runs
Here's the gaps-and-islands trick in two steps.
- Mark each draw where a new run starts:
1when the jackpot dropped,0otherwise. - Take a running total of those marks with
SUM(...) OVER (ORDER BY draw_date). The total goes up by one at the start of each run and stays the same inside it, so it works as a run number.
Then GROUP BY the run number, the same way Part 1 grouped by ball:
WITH flagged AS (
SELECT draw_date,
jackpot,
CASE WHEN jackpot < LAG(jackpot) OVER (ORDER BY draw_date)
THEN 1 ELSE 0 END AS new_run
FROM powerball_draws
),
runs AS (
SELECT draw_date,
jackpot,
SUM(new_run) OVER (ORDER BY draw_date) AS run_id
FROM flagged
)
SELECT MIN(draw_date) AS run_started,
MAX(draw_date) AS last_draw,
COUNT(*) AS draws_in_run,
MAX(jackpot) AS top_jackpot
FROM runs
GROUP BY run_id
ORDER BY draws_in_run DESC, run_started
LIMIT 10;Result:
| run_started | last_draw | draws_in_run | top_jackpot |
|---|---|---|---|
| 2025-09-08 | 2025-12-24 | 47 | 1816800000 |
| 2026-05-02 | 2026-08-12 | 45 | 1040000000 |
| 2025-06-02 | 2025-09-06 | 42 | 1787400000 |
| 2021-06-09 | 2021-10-04 | 41 | 699800000 |
| 2022-08-06 | 2022-11-07 | 41 | 2040100000 |
| 2024-01-03 | 2024-04-06 | 41 | 1325900000 |
| 2021-10-06 | 2022-01-05 | 40 | 632600000 |
| 2023-04-22 | 2023-07-19 | 39 | 1079800000 |
| 2020-09-19 | 2021-01-20 | 36 | 731000000 |
| 2023-07-22 | 2023-10-11 | 36 | 1764900000 |
Step 4: Check the answer against official records
- September 8 to December 24, 2025, 47 draws. Powerball says the December 24 drawing "was the 47th in the jackpot run," a record for the game, and that the jackpot was previously won on September 6 (Powerball.com). That matches.
- August 6 to November 7, 2022, 41 draws. The Associated Press reported on November 6, 2022 that there had been 40 drawings without a winner since the jackpot was won on August 3. Powerball lists the record $2.04 billion jackpot as won on November 7, 2022 (Powerball.com), the next drawing, making 41 draws. That matches.
- May 2 to August 12, 2026, 45 draws. Powerball says the August 12 drawing was the 44th in the run after the jackpot was last won on May 2 (Powerball.com). The query gets 45, because the missed May 2 win from Step 2 put the May 2 drawing at the start of this run instead of the end of the last one. The right answer is 44.
Two more caveats apply to any table like this. The first run starts before the table does, so its length is cut short, and the last run is still going, so it isn't finished.
Step 5: How long do runs usually last?
A CASE expression sorts values into labeled buckets, a handy way to build a histogram in SQL:
WITH flagged AS (
SELECT draw_date,
jackpot,
CASE WHEN jackpot < LAG(jackpot) OVER (ORDER BY draw_date)
THEN 1 ELSE 0 END AS new_run
FROM powerball_draws
),
runs AS (
SELECT draw_date,
jackpot,
SUM(new_run) OVER (ORDER BY draw_date) AS run_id
FROM flagged
),
run_lengths AS (
SELECT run_id, COUNT(*) AS draws_in_run
FROM runs
GROUP BY run_id
)
SELECT CASE WHEN draws_in_run < 10 THEN '1-9'
WHEN draws_in_run < 20 THEN '10-19'
WHEN draws_in_run < 30 THEN '20-29'
WHEN draws_in_run < 40 THEN '30-39'
ELSE '40+' END AS run_length,
COUNT(*) AS runs
FROM run_lengths
GROUP BY run_length
ORDER BY MIN(draws_in_run);Result:
| run_length | runs |
|---|---|
| 1-9 | 17 |
| 10-19 | 32 |
| 20-29 | 14 |
| 30-39 | 8 |
| 40+ | 7 |
Most runs end within 30 draws. Runs of 40 or more, the ones that produce billion-dollar headlines, are rare. The Step 1 rows show how fast a jackpot climbs late in a long run: more than $150 million a draw in the last week of the 2025 run. Our Powerball jackpot history covers the biggest ones.
Try it yourself
- Fix the back-to-back problem. One approach: treat a draw as a win if the next jackpot is lower or if both are at the starting amount. (Check how that behaves elsewhere in the table before trusting it.)
- Find the shortest runs by changing the sort to
ORDER BY draws_in_run. - Find how much the jackpot grew per draw in each run with
(MAX(jackpot) - MIN(jackpot)) / COUNT(*).
About the practice data
The sample files come from the DrawAnalytics results database, the same records behind our Powerball pages and state results pages. They're free to use; if you publish something made with them, please credit DrawAnalytics with a link.
- powerball_draws: all 1,440 Powerball draws from October 7, 2015, the first drawing under today's 5-of-69 plus 1-of-26 format, to November 30, 2026. One row per draw: the five white balls (
n1ton5, smallest first), the redpowerball, the Power Play multiplier and the advertisedjackpotfor that draw. - pick_draws: the 50,956 Pick 3 and Pick 4 style draws from 2025 in our database, across every state game we track, one row per draw, with the number kept as text so a leading zero stays (
'073').
Two things are worth knowing. The jackpot column is the jackpot advertised for each draw; for a draw where the jackpot was won, it's the amount the lottery announced, which can be a little higher than the estimate before the draw. And a few individual draws in our database have been wrong before, so for anything that matters, such as checking a ticket, use the lottery's official results. Powerball's are at powerball.com. Developers who want more data can use our free results API.
Next: Part 4: Same number, same day, different states
Sources
- $1.817 Billion Powerball Jackpot Won in Arkansas, Powerball.com (Dec. 25, 2025)
- Powerball Draw Result, Sat, Dec 27, 2025, Powerball.com
- Powerball winning streak continues with back-to-back jackpot winners, Powerball.com (May 3, 2026)
- Single ticket wins $847 million Powerball jackpot in New Jersey, Powerball.com (Nov. 5, 2026)
- $1.040 Billion Powerball Jackpot Won in Illinois, Powerball.com (Aug. 13, 2026)
- Powerball jackpot nears $2 billion after 40 drawings without winner, Associated Press via Fortune (Nov. 6, 2022)
- Powerball, Wikipedia
- Window Functions, SQLite documentation
DrawAnalytics is an informational service. We do not sell predictions or guarantee outcomes. Lottery drawings are random — past results do not predict future drawings. Play responsibly. 1-800-GAMBLER.