Solved

ms access query to find % of invoice amt per plant

Posted on 2015-02-13
3
182 Views
Last Modified: 2015-02-13
I have a table that has the following columns:
invoice      Plant    Case_Inv_Amt     Tot_Inv_amt
3115          02               100                   500
3115          02                100                   500
3115          02                 100                 500
3115          05                 100                 500
3115          05                 100                 500
4225          02                  50                   200
4225          05                  50                  200
4225          05                  50                  200
4225          05                  50                  200
etc...............

I need to determine how much of the invoice amount is by plant - so I am looking for the following result:

invoice      Plant           Amt_Per_Plant      Tot_Inv_amt
3115          02                300                           500
3115          05                200                           500
4225          02                50                             200
4225          05                150                           200

Or I could use it in this format:

invoice      Amt_02          Amt_05                   Tot_Inv_amt
3115          300                200                           500
4225          50                  150                           200


I am thinking I need to do a few queries - I need to determine the weighted average for each plant -

Any suggestions

Thanks,
0
Comment
Question by:johnmadigan
  • 2
3 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 40609178
create a query like this

select invoice, Plant, Sum(Case_Inv_Amt) as Amt_Per_Plant, Tot_Inv_amt
from Tablex
group by invoice, Plant, Tot_Inv_amt

this should give you


invoice      Plant           Amt_Per_Plant      Tot_Inv_amt
 3115          02                300                           500
 3115          05                200                           500
 4225          02                50                             200
 4225          05                150                           200
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40609196
if you are looking for the percentage
use this query

select  T.invoice, T.plant,T.Amt_Per_Plant,T.Tot_Inv_amt,  Format([Amt_Per_Plant ]/[Tot_Inv_amt],"Percent") as Percentage
From
(
SELECT Table1.invoice, Table1.plant, Sum(Table1.Case_Inv_Amt) AS Amt_Per_Plant, Table1.Tot_Inv_amt
FROM Table1
GROUP BY Table1.invoice, Table1.plant, Table1.Tot_Inv_amt
) As T
0
 

Author Closing Comment

by:johnmadigan
ID: 40609217
Great - thanks so much for your help.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server views 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 Access…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

822 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