I keep baseball statistics in a few tables. SQL 2000 running on Windows Server 2003 sp1.
I am writing a stored procedure which will output a box score for the game. the problem is that if a person in the game has 0 at bats, a divide by zero error occurs as that is how it is calculated.
What I want to do in my select statement, is IF their at bats is 0, then return 0, otherwise calculate the batting average and return that value instead.
so I guess some pseudocode would be:
, IF AtBats = 0
return 0 for a batting average
calculate the batting average and return it