>Hi:
>
>I have the following code with an iif statement to avoid division by zero. BUT I'm getting zero in all the records even though there should only be a zero in the first.
>
>What is the correct syntax?
>
>Thanks,
>
Yossi,
Assuming you're using VFP9, you may use CAST function to create it correctly:
SELECT CAST (IIF(feedweight = 0,0,feedcost / feedweight) as N(10,4)) feedcostperlb ;
FROM prextab ;
INTO CURSOR test
Also please note, that I switched the check, e.g. you need to check for FeedWeight = 0 instead.
If it's not broken, fix it until it is.
My Blog