Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Group By does not return right result with multiple tabl
Message
 
 
À
18/01/2007 20:29:28
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
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 8 SP1
Database:
Visual FoxPro
Divers
Thread ID:
01186807
Message ID:
01186913
Vues:
37
>>And every record in Trans may or may not have records in payments or charges.
>
>Then make those both left joins instead of inner joins, and use nvl()... like this:
>
>
>Select Trans.cTrans_fk, Sum(nvl(Payments.yAmount_paid,0)) as yAmount_paid, ;
>   Sum(nvl(Charges.yCharges_amount,0)) as yCharges_amount ;
>   from Trans ;
>   left join Payments ;
>      on Trans.cTrans_pk = Payments.cTrans_fk ;
>   left join Charges ;
>      on Trans.cTrans_pk = Charges.cTrans_fk ;
>   group by 1
>
>With inner joins you see only transactions where you have records in all three tables for a given transaction.

I believe it's a solution to the problem except that you probably need to put 0000000000.00 (as many 0 as the final field should be).

UPDATE. But it turned out I was wrong and the query doesn't work correctly.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform