Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Received / Outgoing Product
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01210081
Message ID:
01210577
Vues:
17
This came out way off on the resulting Quantity for "QtyIn". It is in reality 221 for a specific customer, but the SQL statement made it come out as 4 times that value, meaning 884.

Perhaps you are correct in your statement that 3 tables will give the wrong values in a SQL Statement. The statement seems logical, but it came out wrong in its sum of the QtyIn value. Here's the code I ended up using which is a summation of several of those who contributed here:
SELECT ;
      CustNo, Customer, QtyIn, QtyOut, QtyIn-QtyOut As QtyDiff ;
   FROM ( ;
      SELECT ;
            cs.CustNo, ;
            cs.Customer, ;
            SUM(NVL(si.StandsIn,0)) AS QtyIn, ;
            SUM(NVL(so.SerialCnt,0)) As QtyOut ;
         FROM Customer cs ;
         LEFT JOIN StandsIn si ON si.cust = cs.custno ;
         LEFT JOIN Stands_Out so ON so.cust = cs.custno ;
         GROUP BY ;
            cs.CustNo, ;
            cs.Customer ;
   ) dt1
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform