Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL and the WHERE clause
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00897390
Message ID:
00897454
Views:
14
Hi Barbara,

In this case the problem is incorrect WHERE clause condition which includes records where one and only one of divisors ( onhand, avgprice) is 0.
onhand  avgprice Included?  onhand<>0  avgprice <> 0   WHERE condition (OR)  
   0       0        No         .F.        .F.          .F.
   1       0       Yes         .T.        .F.          .T. - Should not be included
   0       1       Yes         .F.        .T.          .T. - Should not be included
   1       1       Yes         .T.        .T.          .T.
I also don't believe that columns are evaluated before the records are filtered. I would appreceate if you can provide any code that demonstrates that.

>I think Chuck meant to use the WHERE clause to filter out records where the divisor would be 0, in which case he did want OR, not AND. The problem is, the WHERE clause doesn't work this way. You can't count on the filter being evaluated before it looks at ANY records, which I think is the problem.
>
>>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
>>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform