SELECT item, ROUND(qtyship / (onhand * avgprice),2) AS per_shp ; FROM inventory ; WHERE onhand <> 0 AND avgprice <> 0>We wanted to do some math in the SQL statement. So we have a SQL statement
>SELECT item, qtyship / (onhand * avgprice) AS per_shp FROM inventory WHERE onhand <> 0 .OR. avgprice <> 0 >>but we get currency value out side of range. If I change the SQL statement to be
>SELECT item, qtyship / IIF(onhand * avgprice = 0, 1, (onhand * avgprice)) AS per_shp FROM inventory WHERE onhand <> 0 .OR. avgprice <> 0 >>then it works. Why do I have to trap for the divide by zero twice? Shouldn't the where clause be enough? I'm using VFP 6 SP5.