Solved

Sum the values from 2 different queries in 1 query

Posted on 2013-06-13
2
467 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 360 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

728 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