Hi,
you can try to look the manual for select IF(expr1,expr2,expr3);
It return expr2 if expr1 is true, else expr3.
So you can try this:
$strSQL=$strSQL."IF( (".$table2.".".$pre2.$yr_array[$j].">0),(".$table.".".$pre.$yr_array[$j]."/".$table2.".".$pre2.$yr_array[$j]."), ('zero')) as " .$newpre.$yr_array[$j];
But i never use it first...