Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sum problem
Message
De
12/05/2000 10:36:39
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00368840
Message ID:
00369051
Vues:
15
Hi Jim,

Your query produces better results BUT.... two rows for each T1 record and you cannot distinguish the amounts as to source (T2 OR T3). So if I am trying to construct a view containing Invoice total charges and Invoice total payments as separate fields I am SOL it appears. Looks like it has to be done programatically or thru a series of queries, to build a cursor that can support a grid.

Ken

>Folks,
>
>Here's what is happening. The sums are what the SELECT is asking for.
>
>We have one Id the 1, in the T2 table tehre are three matching records on that ID, and in T3 there are two matching records. The joins produce a result of 6 records, the joining of T1 with T2 gives three and then joining T3 gives the 6, one of each of the 3 for each of the T3 records. A listing is below;
>
>
>T1 RecNo    T2 Recno   T3 Recno  T2 Amount   T3 Amount
>1               1         1         50           10
>1               2         1         60           10
>1               3         1         40           10
>1               1         2         50           15
>1               2         2         60           15
>1               3         2         40           15
>SUM                                300           75
>
>
>A GROUP BY will not change this, it will only hide the actual records produced in the JOIN. Perhaps the following SELECT will be more appropriate for the job;
>
>
>SELECT T1.Id, T2.Id, SUM(T2.Amount) ;
>  FROM T1 INNER JOIN T2 ON T1.ID = T2.Fid ;
> UNION ALL ;
> SELECT T1.ID, T3.Id, SUM(T3.Amount) ;
>   FROM T1 INNER JOIN T3 ON T1.ID = T3.Fid ...
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform