At 7:46 PM -0600 10/30/01, Camilo Rostoker wrote: >Hi. > >I have a query that determines the ranking of teams in a league by >several calculations on the table. Below is the query: > >SELECT TeamName,TeamWins,TeamLosses,TeamSpirit, >(TeamSpirit/(TeamWins+TeamLosses)*100) AS AvgSpirit, >((TeamWins*2)-TeamLosses) AS TeamPoints >FROM Teams_1 >WHERE DivisionName = 'A Division' >AND LeagueID = 1 >ORDER BY TeamPoints,AvgSpirit > >But the newly created attribute, AvgSpirit, will fail when a team has >not won or lost a game ... > >Any ideas on how to remedy this problem?
Change: (TeamSpirit/(TeamWins+TeamLosses)*100) AS AvgSpirit, to: IFNULL((TeamSpirit/(TeamWins+TeamLosses)*100),0) AS AvgSpirit, > >Thanks for the help, >Camilo Rostoker --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php