Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL select to sum from two tables?
Message
De
03/06/2009 16:24:06
 
 
À
03/06/2009 16:10:55
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01403521
Message ID:
01403532
Vues:
43
>How would you select a sum of fields from 2 child tables for the parent key?
>
>Here is the pseudo code of what I need:
>
>select (sum(hrs*rate) from Labor where Labor.ifkey=Job.ipkey) + (sum (qty*price) from Material where Material.ifkey=Job.ipey) as TotalCost
How about something like
SELECT SUM( (labor.hrs * labor.rate) + (material.qty * material.price)) AS total cost;
  FROM labor;
    JOIN material ON labor.ifkey = material.ifkey;
  WHERE labor.ifkey = job.ipkey
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform