Hi!
I am trying to generate a league table from a sports league automatically by
using ASP and a Database.
I want to register the results in a database table which looks like this:
TABLE NAME: League
id*
season
round
hometeam_id
awayteam_id
hometeam_score
awayteam_score
I then use SUM and COUNT functions to add the team's scores up. This is
going pretty well.
Then comes my problem - how do i sort the league table so that the team with
the most points comes first?
It should be sorted first on points, then on (goals_scored - goals_conceded)
and finally on goals scored.
Until now I have put each team in an array like this
teamA = "teamName, played, won, drawn, lost, goals_scored, goals_conceded,
points"
How do I go about sorting this? I have heard about an algorithm called
bubble sort, but I looked at it and couldn't quite figure it out.
Also I have the problem that if a team has played, say only 1 game, and
scored 0 goals, the output from the SUM() of goals isn't 0 but "".
How can I fix this?
I would REALLY appreciate if someone took the time to help me out here!
Thanks!
Quinn
|