Solved

Sum in a Query (Balance)

Posted on 2014-12-16
9
85 Views
Last Modified: 2014-12-16
Experts,
I have a query with [FacilityAmount] and [Amount].  
There are 3 Facilities and each has an [Amount] (this is the amount drawn)
I need to show the [AvailableAmount] for each Facility, which is found by [FacilityAmount] and [Amount]
I think it is quite simple but I dont know how to do it.

I think it will be more clear if you open the attached db and look at the query.

query picDatabase1.accdb
0
Comment
Question by:pdvsa
  • 5
  • 4
9 Comments
 

Author Comment

by:pdvsa
ID: 40502999
I basically need a sum for [Amount] (this is the amount drawn) but for each [Facility]
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 40503024
see query1
Database1Rev.accdb
0
 

Author Comment

by:pdvsa
ID: 40503071
Hi Rey,

I am not sure if the calc is correct because the FacilityAmount is as follows:
Uncovered      $2,915,000,000.00
Nexi             $2,000,000,000.00
JBIC                     $2,500,000,000.00
      
but in the query1 (below) it shows a sum of the FacilityAmount (basically doubling it):  
ie:  JBIC shows 5Billion and it should be 2.5Billiion (as above) and a SumOfAvailable should be: 2.5 - the sum  tblDisbursement_Amounts where it = JBIC

Type      SumOfFacilityAmount      SumOfAvailable
JBIC                $5,000,000,000.00      $4,877,000,000.00
NEXI         $4,000,000,000.00      $3,905,000,000.00
Uncovered      $5,830,000,000.00$5,690,000,000.00

thank you
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 40503108
open first the query Q1
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 119

Expert Comment

by:Rey Obrero
ID: 40503115
see Q2 and query2
Database1Rev.accdb
0
 

Author Comment

by:pdvsa
ID: 40503170
Rey:  thank you sir...Can you look at that query2 once more?  

example:  JBIC available should be :  2.5B - sum(25MM+98MM) = 2.377B

The facility amount doesnt appear to be correct.  Ie: JBIC shows 5B and it should be 2.5B.  The sumOfAmount is correct though.
0
 

Author Comment

by:pdvsa
ID: 40503174
all of the [FacilityAmounts] appear to be doubled and not just JBIC
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 40503207
ok, first create a query

SELECT tblDisbursement_Amounts.Type, Sum(tblDisbursement_Amounts.Amount) AS SumOfAmount
FROM tblDisbursement_Amounts
WHERE (((tblDisbursement_Amounts.DisbRecdDate) Is Not Null))
GROUP BY tblDisbursement_Amounts.Type;

save as Q_Disbursement

then create this query

SELECT Q_Disbursement.Type, tblFacilityAmounts.FacilityAmount, Q_Disbursement.SumOfAmount, [FacilityAmount]-[SumOfAmount] AS Available
FROM Q_Disbursement INNER JOIN tblFacilityAmounts ON Q_Disbursement.Type = tblFacilityAmounts.Type;


check the result
0
 

Author Closing Comment

by:pdvsa
ID: 40503244
Wow that works.  Now I need to figure out how you did it.  

thank you
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

760 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now