?
Solved

Sum the values from 2 different queries in 1 query

Posted on 2013-06-13
2
Medium Priority
?
476 Views
Last Modified: 2013-06-13
Hi Experts

I have the 2 queries below, each of which gives me one number.  I want to be able to create a query which uses these 2 queries as subqueries so the 2 values can be summed and I have one total.  Can you help?

SELECT Sum([Pnl by GL - Accounting result].[SumOf7 Total Pnl YTD]) AS GL_ACCOUNTING
FROM [Pnl by GL - Accounting result]
WHERE ((([Pnl by GL - Accounting result].ReportCategory)="HTM" Or ([Pnl by GL - Accounting result].ReportCategory)="Loans&Receivables") AND (([Pnl by GL - Accounting result].AcctArea)="BA_AMADEUS" Or ([Pnl by GL - Accounting result].AcctArea)="BA_TOP_UP" Or ([Pnl by GL - Accounting result].AcctArea)="BA_CDS_HDG" Or ([Pnl by GL - Accounting result].AcctArea)="HENDERSON") AND (([Pnl by GL - Accounting result].AccountCode)=5865000000));

and

SELECT Sum([PnL by GL - Interest].[SumOf11 TotalInterest]) AS GL_INTEREST
FROM [PnL by GL - Interest]
WHERE ((([PnL by GL - Interest].ReportCategory)="Loans&Receivables" Or ([PnL by GL - Interest].ReportCategory)="HTM") AND (([PnL by GL - Interest].AcctArea)="BA_AMADEUS" Or ([PnL by GL - Interest].AcctArea)="BA_TOP_UP" Or ([PnL by GL - Interest].AcctArea)="BA_CDS_HDG" Or ([PnL by GL - Interest].AcctArea)="HENDERSON"));
0
Comment
Question by:simsima_7876
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 1440 total points
ID: 39244083
Select q1.GL_ACCOUNTING+q2.GL_INTEREST as Mytotal from

(SELECT Sum([Pnl by GL - Accounting result].[SumOf7 Total Pnl YTD]) AS GL_ACCOUNTING
FROM [Pnl by GL - Accounting result]
WHERE ((([Pnl by GL - Accounting result].ReportCategory)="HTM" Or ([Pnl by GL - Accounting result].ReportCategory)="Loans&Receivables") AND (([Pnl by GL - Accounting result].AcctArea)="BA_AMADEUS" Or ([Pnl by GL - Accounting result].AcctArea)="BA_TOP_UP" Or ([Pnl by GL - Accounting result].AcctArea)="BA_CDS_HDG" Or ([Pnl by GL - Accounting result].AcctArea)="HENDERSON") AND (([Pnl by GL - Accounting result].AccountCode)=5865000000))) as q1,

(SELECT Sum([PnL by GL - Interest].[SumOf11 TotalInterest]) AS GL_INTEREST
FROM [PnL by GL - Interest]
WHERE ((([PnL by GL - Interest].ReportCategory)="Loans&Receivables" Or ([PnL by GL - Interest].ReportCategory)="HTM") AND (([PnL by GL - Interest].AcctArea)="BA_AMADEUS" Or ([PnL by GL - Interest].AcctArea)="BA_TOP_UP" Or ([PnL by GL - Interest].AcctArea)="BA_CDS_HDG" Or ([PnL by GL - Interest].AcctArea)="HENDERSON"))) as q2
0
 

Author Closing Comment

by:simsima_7876
ID: 39244092
Thanks very much.  Super quick!
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question