mtagliaferri
Registered User.
- Local time
- Today, 12:38
- Joined
- Jul 16, 2006
- Messages
- 550
I have a discrepancy with the number of records returned...the original functioning qry was that returned the correct number of records was
I added to the qry a further try "qryHotacBills" to extract further data and the new qry is
As I added the "qryHotacBill" I have extra records extracted, I researched what records are and I have discovered that in the "tblAdditionalAllowances" I have occasionally 2 or 3 records with the same date and these should be added as total under that date hence this bit of code (qryHotacBill run separately works)
In the first qry it does sum the amounts however when I added "qryHotacBill" It no longer returns the sum of additional allowances. I have checked the joint properties and I cant see the error...
What am I getting wrong? :banghead:
Code:
SELECT tblTrip.IDTrip, tblTrip.TripDate, tblTrip.NDays, tblTrip.TAFB, tblTrip.DutyPayRate, [TAFB]*[DutyPayRate] AS [Duty Pay], tblTrip.PSR, tblTrip.DutyType, qryFlightTimeOperation.[Tot Flying Time], qryFlightTimeOperation.[Tot Sectors], qryFlightTimeOperation.[Non Operating Sectors], qryFlightTimeOperation.[Operating Sectors], Sum(tblAdditionalAllowances.AmmountAdditionalAllowances) AS AdditionalAllowances
FROM (tblTrip LEFT JOIN qryFlightTimeOperation ON tblTrip.IDTrip = qryFlightTimeOperation.IDTrip) LEFT JOIN tblAdditionalAllowances ON tblTrip.IDTrip = tblAdditionalAllowances.IDTrip
GROUP BY tblTrip.IDTrip, tblTrip.TripDate, tblTrip.NDays, tblTrip.TAFB, tblTrip.DutyPayRate, [TAFB]*[DutyPayRate], tblTrip.PSR, tblTrip.DutyType, qryFlightTimeOperation.[Tot Flying Time], qryFlightTimeOperation.[Tot Sectors], qryFlightTimeOperation.[Non Operating Sectors], qryFlightTimeOperation.[Operating Sectors]
ORDER BY tblTrip.TripDate;
I added to the qry a further try "qryHotacBills" to extract further data and the new qry is
Code:
SELECT tblTrip.IDTrip, tblTrip.TripDate, tblTrip.NDays, tblTrip.TAFB, tblTrip.DutyPayRate, [TAFB]*[DutyPayRate] AS [Duty Pay], tblTrip.PSR, tblTrip.DutyType, qryFlightTimeOperation.[Tot Flying Time], qryFlightTimeOperation.[Tot Sectors], qryFlightTimeOperation.[Non Operating Sectors], qryFlightTimeOperation.[Operating Sectors], Sum(tblAdditionalAllowances.AmmountAdditionalAllowances) AS AdditionalAllowances, qryHotacBill.HotacBill, [TAFB]*[DutyPayRate]+Nz([AmmountAdditionalAllowances],0) AS TOT
FROM ((tblTrip LEFT JOIN qryFlightTimeOperation ON tblTrip.IDTrip = qryFlightTimeOperation.IDTrip) LEFT JOIN tblAdditionalAllowances ON tblTrip.IDTrip = tblAdditionalAllowances.IDTrip) LEFT JOIN qryHotacBill ON tblTrip.IDTrip = qryHotacBill.IDTrip
GROUP BY tblTrip.IDTrip, tblTrip.TripDate, tblTrip.NDays, tblTrip.TAFB, tblTrip.DutyPayRate, [TAFB]*[DutyPayRate], tblTrip.PSR, tblTrip.DutyType, qryFlightTimeOperation.[Tot Flying Time], qryFlightTimeOperation.[Tot Sectors], qryFlightTimeOperation.[Non Operating Sectors], qryFlightTimeOperation.[Operating Sectors], qryHotacBill.HotacBill, [TAFB]*[DutyPayRate]+Nz([AmmountAdditionalAllowances],0)
ORDER BY tblTrip.TripDate;
As I added the "qryHotacBill" I have extra records extracted, I researched what records are and I have discovered that in the "tblAdditionalAllowances" I have occasionally 2 or 3 records with the same date and these should be added as total under that date hence this bit of code (qryHotacBill run separately works)
Code:
Sum(tblAdditionalAllowances.AmmountAdditionalAllowances) AS AdditionalAllowances
In the first qry it does sum the amounts however when I added "qryHotacBill" It no longer returns the sum of additional allowances. I have checked the joint properties and I cant see the error...
What am I getting wrong? :banghead: