You need a CASE statement.
http://www.mysql.com/doc/en/CASE_Statement.html
[code]
select home_team, home_score, away_team, away_score,
case
when home_score>away_score then 'W'
when home_score<away_score then 'L'
else 'D'
end as outcome
from ......
[\code]
Quote:
Originally posted by jimmy2bob
is it possible to have a colum that calculates something?
what i'm wanting to do is calculate if the team has won drawn or lost. I know how do do this in excel,
if team A is at home then
{If homescore > awayscor = W
if awayscore < homescore = L
else D
}
if team A is away then....
Home Team Score Away Team Score Outcome
Team 1 2 Team 12 1 ?
Team 3 1 Team 5 1 ?
etc...
hope anyone can help
jamie
|