Solved

ms access query to find % of invoice amt per plant

Posted on 2015-02-13
3
176 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 119

Accepted Solution

by:
Rey Obrero 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 119

Expert Comment

by:Rey Obrero
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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 …

747 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

12 Experts available now in Live!

Get 1:1 Help Now