I am trying to count the number of rows until the first occurrence of distinct value, for every distinct value.
Table example
game winner
-----------
1 Mark
2 Joe
3 Mark
4 Paula
5 Paula
6 Paula
7 Joe
8 Anna
With query below i get this..
SELECT winner,COUNT(*) as count FROM tablename GROUP BY winner;
Result
Mark won 2 games
Joe won 2 games
Paula won 3 games
Anna won 1 game
Below are the results that I want to get:
Mark won 2 games, but didn't won last 6 games
Joe won 2 games, but didn't won last 1 games
Paula won 3 games, but didn't won last 2 games
Anna won 1 game, but didn't won last 0 games
Thank you for taking the time to help me, I really appreciate it.