Advanced Nested Queries Ms Access

Hi Experts

I have two queries below used for the calculation of net pay:

Background

(1) Query One & Two are required calculate all number based controls on a cumulative basis, example sum (BasicSalary+HousingAllowance+TransportAllowance+LunchAllowance+XmasBonus+OtherBonuses+Gratuity+LeavePay+OtherArears+(Overtime*Rate)) As Gross
(2) Query One & Two are required calculate all number based controls on a cumulative basis Example  Sum(FreeTax) As TaxFree

(3) Finally the results Query one - the results query two is what I realy require to perform the final calculations

I understand that the solution is on the nested query, any idea how I can combine the two queries so that the results of Query one is substracted from the result of query two.I'm sure by now you have seen that Query one is always one month aheard while query two is behind by one month because our tax system is calculated on cummulative basis.Below are the said queries.

Query One

SELECT QryPaySlipFinalConso.EmpID, QryPaySlipFinalConso.Fname, QryPaySlipFinalConso.Lname, QryPaySlipFinalConso.StaffNumber, QryPaySlipFinalConso.JobTitle, QryPaySlipFinalConso.SocialSecurity, QryPaySlipFinalConso.NRC, QryPaySlipFinalConso.PayMethod, QryPaySlipFinalConso.BankName, QryPaySlipFinalConso.AccountCode, QryPaySlipFinalConso.PaymentType, QryPaySlipFinalConso.BasicSalary, QryPaySlipFinalConso.HousingAllowance, QryPaySlipFinalConso.TransportAllowance, QryPaySlipFinalConso.LunchAllowance, QryPaySlipFinalConso.TTDate, QryPaySlipFinalConso.XMasBonus, QryPaySlipFinalConso.OtherBonuses, QryPaySlipFinalConso.Gratuity, QryPaySlipFinalConso.LeavePay, QryPaySlipFinalConso.OtherArears, QryPaySlipFinalConso.Overtime, QryPaySlipFinalConso.DoubleTime, QryPaySlipFinalConso.OtherIncentive, QryPaySlipFinalConso.StaffLoans, QryPaySlipFinalConso.OtherDeductions, QryPaySlipFinalConso.Advances, QryPaySlipFinalConso.Rate, QryPaySlipFinalConso.CelingRate, QryPaySlipFinalConso.NAPSAFree, QryPaySlipFinalConso.FreeTax, QryPaySlipFinalConso.BandOne, QryPaySlipFinalConso.BandTwo, QryPaySlipFinalConso.TaxRateone, QryPaySlipFinalConso.TaxRateTwo, QryPaySlipFinalConso.TaxRateThree, QryPaySlipFinalConso.EducationLevy, QryPaySlipFinalConso.Gross, QryPaySlipFinalConso.Pension, QryPaySlipFinalConso.Taxable, QryPaySlipFinalConso.LeaveDays, QryPaySlipFinalConso.LeaveTaken, QryPaySlipFinalConso.VFTaxable, QryPaySlipFinalConso.Status
FROM QryPaySlipFinalConso
WHERE (((QryPaySlipFinalConso.EmpID)=[Forms]![frmpayslipsprint]![CboFirstName]) AND ((QryPaySlipFinalConso.TTDate)<=(Format(([Forms]![frmpayslipsprint]![txtSalaryEnddate]),"yyyy\/mm\/dd"))) AND ((QryPaySlipFinalConso.Status) Is Null)) OR (((QryPaySlipFinalConso.Status)<>"1"));

Query Two

SELECT QryPaySlipFinalConso.EmpID, QryPaySlipFinalConso.Fname, QryPaySlipFinalConso.Lname, QryPaySlipFinalConso.StaffNumber, QryPaySlipFinalConso.JobTitle, QryPaySlipFinalConso.SocialSecurity, QryPaySlipFinalConso.NRC, QryPaySlipFinalConso.PayMethod, QryPaySlipFinalConso.BankName, QryPaySlipFinalConso.AccountCode, QryPaySlipFinalConso.PaymentType, QryPaySlipFinalConso.BasicSalary, QryPaySlipFinalConso.HousingAllowance, QryPaySlipFinalConso.TransportAllowance, QryPaySlipFinalConso.LunchAllowance, QryPaySlipFinalConso.TTDate, QryPaySlipFinalConso.XMasBonus, QryPaySlipFinalConso.OtherBonuses, QryPaySlipFinalConso.Gratuity, QryPaySlipFinalConso.LeavePay, QryPaySlipFinalConso.OtherArears, QryPaySlipFinalConso.Overtime, QryPaySlipFinalConso.DoubleTime, QryPaySlipFinalConso.OtherIncentive, QryPaySlipFinalConso.StaffLoans, QryPaySlipFinalConso.OtherDeductions, QryPaySlipFinalConso.Advances, QryPaySlipFinalConso.Rate, QryPaySlipFinalConso.CelingRate, QryPaySlipFinalConso.NAPSAFree, QryPaySlipFinalConso.FreeTax, QryPaySlipFinalConso.BandOne, QryPaySlipFinalConso.BandTwo, QryPaySlipFinalConso.TaxRateone, QryPaySlipFinalConso.TaxRateTwo, QryPaySlipFinalConso.TaxRateThree, QryPaySlipFinalConso.EducationLevy, QryPaySlipFinalConso.Gross, QryPaySlipFinalConso.Pension, QryPaySlipFinalConso.Taxable, QryPaySlipFinalConso.LeaveDays, QryPaySlipFinalConso.LeaveTaken, QryPaySlipFinalConso.VFTaxable, QryPaySlipFinalConso.Status
FROM QryPaySlipFinalConso
WHERE (((QryPaySlipFinalConso.EmpID)=[Forms]![frmpayslipsprint]![CboFirstName]) AND ((QryPaySlipFinalConso.TTDate)<(Format(([Forms]![frmpayslipsprint]![txtSalaryStartDate]),"yyyy\/mm\/dd"))) AND ((QryPaySlipFinalConso.Status) Is Null)) OR (((QryPaySlipFinalConso.Status)<>"1"));

The results need to be ORDERED BY EMPID

Regards

Chris
LVL 3
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScDirectorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
I understand that the solution is on the nested query, any idea how I can combine the two queries so that the results of Query one is substracted from the result of query two

Please rephrase your question, otherwise, it is a LEFT JOIN over all columns, where the joined side is NULL for the key(s). Define "substracted".
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.