Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
More SQL fun ...
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
More SQL fun ...
Miscellaneous
Thread ID:
00057875
Message ID:
00057875
Views:
71
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.
Next
Reply
Map
View

Click here to load this message in the networking platform