Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting Data from Two Tables
Message
De
11/06/2008 13:12:28
 
 
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 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01323156
Message ID:
01323170
Vues:
15
>>>I am using SPT to get remote data from two tables.
>>>
>>>One table(Task Table) has a field called schuledhours. The second table(Assignments Table) is a child of table one with a field called assignedhours. I need a sql that lists the scheduledhours, sum of assignedhours.
>>
>>
>>SELECT TaskTable.*, NVL(Tbl1.SumHours, CAST(0 as int)) AS WholeHours;
>>FROM  TaskTable;
>>LEFT JOIN (SELECT Id, SUM(assignedhours) AS SumHours;
>>                              FROM Assignments;
>>                              GROUP BY Id) Tbl1;
>>ON TaskTable.Id = Tbl1.Id
>>
>>Where Id is the Primary key of TaskTable and FK of Assignments.
>
>Good catch with LEFT JOIN!

:-)
My first thought was INNER, but then I read that Steven wants ALL records from Tasks :-)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform