Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
measterbro
Starting Member
2 Posts |
Posted - 2014-11-05 : 12:05:14
|
I have a Games table in a SQL Server 2012 database with game results from our league, including home and away scores, dates, and teams. How can I query to list streaks - that is, wins or losses of 2 more games in a row throughout a season? |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2014-11-05 : 14:52:35
|
[code]1) You need to define an order on the games in order to find the "next" game for any entry; without your schema, I'd only be guessing.2) A streak is any two games for the same team that have: a) the same result (W or L) b) and there does not exist a game between them (See above) with a different result c) and i) there does exist the "next" game (See above) after the end with a different result OR ii) there does not exist a "next" game (See above)[/code] No amount of belief makes something a fact. -James Randi |
|
|
|
|
|