Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Statement in SELECT
Message
 
 
To
16/12/2007 09:26:25
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01276157
Message ID:
01276161
Views:
22
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform