If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Help with streaks

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-26-08, 17:18
jensen jensen is offline
Registered User
 
Join Date: Nov 2008
Posts: 1
Help with streaks

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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On