I'm trying to work in http://www.sqlteam.com/article/detec...s-in-your-data , the output is exactly what I'm trying to achieve.

I'm trying to work it around two tables, res and pgram

res:
kampid (id for each match)
hjemmemaal (home score)
udemaal (away score)


pgram:
kampid (id for each match corresponding to res.kampid)
dato (date)
hjemme (id for home team)
ude (id for away team)

Id for teams corresponding to a team-table


I find wins:

SELECT SUM(CASE WHEN res.hjemmemaal > res.udemaal THEN 1 ELSE 0 END) as Wins

FROM pgram AS p
INNER JOIN res AS res
ON p.kampid = res.kampid



Now, challenge 1; I'm trying to work in Jeffs RunGroup:

SELECT GameDate,
Result,
(SELECT COUNT(*)
FROM GameResults G
WHERE G.Result <> GR.Result
AND G.GameDate <= GR.GameDate) as RunGroup
FROM GameResults GR

combining my two tabels pgram and res