Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
More SQL fun ...
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
More SQL fun ...
Divers
Thread ID:
00057875
Message ID:
00057875
Vues:
77
Consider 3 entities in a grandparent parent child relationship:

House Airway Bill (HAWB) grandparent
Shipments - parent
Charges - child

A HAWB can contain multiple shipments and multiple charges can be posted to a shipment.

What is required is a table by HAWB with the total values of the shipments and the total of the charges.

Can one do this in 1 SQL?

select HAWB, sum(shipment.value), sum(charges.amount);
from Shipment,Charges;
where shipment.shipment= charges.shipment;
order by Hawb;
group by Hawb

gives faulty shipment values. The value gets multiplied by the number of charges for each shipment.

Is this a classic, or worse a faq? In native VFP, you can solve the problem with cascated SQLs, but what if you are in an C/S environment? Just curious.

TIA,

Marc

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform