Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL and the WHERE clause
Message
 
 
To
22/04/2004 17:39:21
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00897390
Message ID:
00897401
Views:
13
Chuck,

It should be AND not OR. It would be also a good idea to round result.
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.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform