0

How to make limit for how many games to take from each club, I would like to have only ten games from each club. This is the code for all games which I find here how to output a standings table on the fly from a mysql table of football [soccer] results?

select 
team, 
count(*) played, 
count(case when goalsfor > goalsagainst then 1 end) wins, 
count(case when goalsagainst> goalsfor then 1 end) lost, 
count(case when goalsfor = goalsagainst then 1 end) draws, 
sum(goalsfor) goalsfor, 
sum(goalsagainst) goalsagainst, 
sum(goalsfor) - sum(goalsagainst) goal_diff,
sum(
      case when goalsfor > goalsagainst then 3 else 0 end 
    + case when goalsfor = goalsagainst then 1 else 0 end
) score 
from (
select hometeam team, goalsfor, goalsagainst from scores 
union all
select awayteam, goalsagainst, goalsfor from scores
) a 
group by team
order by score desc, goal_diff desc;
4

1 に答える 1

0

SELECTでLIMIT句を使用して、限られた数の行を返します。
ドキュメント:http ://dev.mysql.com/doc/refman/5.5/en/select.html

于 2012-06-04T15:35:34.720 に答える