Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL and the WHERE clause
Message
 
 
À
22/04/2004 17:39:21
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00897390
Message ID:
00897401
Vues:
14
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--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform