Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


How to Calc Avg Cost for an Item from Item Trans table

How to Calc Avg Cost for an Item from Item Trans table

How to Calc Avg Cost for an Item from Item Trans table

Appreciate some guidance.

Apologize in advance, not a programmer, but, tasked with providing this data.
Can perform std joins and less complicated queries.

Not sure how to store or perform running total. Not sure of best method for gathering this data.

Thanks in advance for your input, awaria

Goal: Calc avg cost for item;

Tables: Item Master and Item Transaction

Item Master has field QtyonHand = 10 for item A

Item QOH
A 10

Item Trans most recent transactions;

Item Qty Cost Date
A 4 10.00 2/28/18
A 4 20.00 2/17/18
A 4 30.00 2/16/18

How to loop through trans table for most recent transactions, selecting the
cost for the 4 from 2/28/18, the cost for 4 from 2/27/18 and then cost for
just 2 out of 4 from 2/26/18 to arrive at an avg cost of $18.00 for the Item Master table's QOH of 10?

RE: How to Calc Avg Cost for an Item from Item Trans table

select (sum (item*qty)) / sum(qty) from ItemTransaction where item = 'A')

Not clear to me how Quantity on Hand affects anything you've asked for. Also, your example looks wrong as they dates seem to be off.

advanced cognitive capabilities and other marketing buzzwords explained with sarcastic simplicity

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close