A
Alain
Hi to All,
I am trying to build a query based on 4 other queries but getting strange
results, my 4 basic queries are returning the sum of monthly results per
year which by themselves are working great, all the retuned numbers are
good, here is the example:
SELECT Projection.IdBranch, Projection.Annee, Projection.ModeDeCalcul,
nz([Projection].[Avril],0)+nz([Projection].[Mai],0)+nz([Projection].[Juin],0)+nz([Projection].[Juillet],0)+nz([Projection].[Aout],0)+nz([Projection].[Septembre],0)+nz([Projection].[Octobre],0)+nz([Projection].[Novembre],0)+nz([Projection].[Decembre],0)+nz([Projection].[Janvier],0)+nz([Projection].[Fevrier],0)+nz([Projection].[Mars],0)
AS YearSum
FROM Projection
WHERE (((Projection.Variante)="Basic Rental"))
ORDER BY Projection.IdBranch, Projection.Annee;
My problem is when I want to build a query that returns the sum of the that
need to return the sum of all 4 queries on a yearly basis, I am not getting
the rights results, here is my query:
SELECT [Q-ProjSumRent].IdBranch, [Q-ProjSumRent].ModeDeCalcul,
Sum([Q-ProjSumRent].[YearSum]+[Q-ProjSumBTV].[YearSum]+[Q-ProjSumOther].[YearSum]+[Q-ProjSumOMT].[YearSum])
AS YearSum
FROM (([Q-ProjSumBTV] RIGHT JOIN [Q-ProjSumRent] ON [Q-ProjSumBTV].IdBranch
= [Q-ProjSumRent].IdBranch) LEFT JOIN [Q-ProjSumOther] ON
[Q-ProjSumRent].IdBranch = [Q-ProjSumOther].IdBranch) LEFT JOIN
[Q-ProjSumOMT] ON [Q-ProjSumRent].IdBranch = [Q-ProjSumOMT].IdBranch
GROUP BY [Q-ProjSumRent].IdBranch, [Q-ProjSumRent].ModeDeCalcul,
[Q-ProjSumRent].Annee
ORDER BY [Q-ProjSumRent].IdBranch;
the tight results should be 57722 for the first idbranch for the first year
but i am getting 1558701
I have tried many combination of relationship, one-to-one, one-to-many but
still getting wrong results.
Can anybody let me know what I am doing wrong ???
Thanks
Alain
I am trying to build a query based on 4 other queries but getting strange
results, my 4 basic queries are returning the sum of monthly results per
year which by themselves are working great, all the retuned numbers are
good, here is the example:
SELECT Projection.IdBranch, Projection.Annee, Projection.ModeDeCalcul,
nz([Projection].[Avril],0)+nz([Projection].[Mai],0)+nz([Projection].[Juin],0)+nz([Projection].[Juillet],0)+nz([Projection].[Aout],0)+nz([Projection].[Septembre],0)+nz([Projection].[Octobre],0)+nz([Projection].[Novembre],0)+nz([Projection].[Decembre],0)+nz([Projection].[Janvier],0)+nz([Projection].[Fevrier],0)+nz([Projection].[Mars],0)
AS YearSum
FROM Projection
WHERE (((Projection.Variante)="Basic Rental"))
ORDER BY Projection.IdBranch, Projection.Annee;
My problem is when I want to build a query that returns the sum of the that
need to return the sum of all 4 queries on a yearly basis, I am not getting
the rights results, here is my query:
SELECT [Q-ProjSumRent].IdBranch, [Q-ProjSumRent].ModeDeCalcul,
Sum([Q-ProjSumRent].[YearSum]+[Q-ProjSumBTV].[YearSum]+[Q-ProjSumOther].[YearSum]+[Q-ProjSumOMT].[YearSum])
AS YearSum
FROM (([Q-ProjSumBTV] RIGHT JOIN [Q-ProjSumRent] ON [Q-ProjSumBTV].IdBranch
= [Q-ProjSumRent].IdBranch) LEFT JOIN [Q-ProjSumOther] ON
[Q-ProjSumRent].IdBranch = [Q-ProjSumOther].IdBranch) LEFT JOIN
[Q-ProjSumOMT] ON [Q-ProjSumRent].IdBranch = [Q-ProjSumOMT].IdBranch
GROUP BY [Q-ProjSumRent].IdBranch, [Q-ProjSumRent].ModeDeCalcul,
[Q-ProjSumRent].Annee
ORDER BY [Q-ProjSumRent].IdBranch;
the tight results should be 57722 for the first idbranch for the first year
but i am getting 1558701
I have tried many combination of relationship, one-to-one, one-to-many but
still getting wrong results.
Can anybody let me know what I am doing wrong ???
Thanks
Alain