Results 1 to 5 of 5
  1. #1
    EMAS is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2015
    Posts
    2

    Last purchase price of a product sale

    Hi, I have a table containing all product purchases (productid, p_date, p_price, ...) and a table containing all product sales (productid, s_date, s_price, ...). I need to calculate the profit of each sale using the latest purchase price at the time of the sale. How do I do that?


    Thanks, E.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,423
    Review http://allenbrowne.com/subquery-01.html#TopN

    Build a query that returns the latest price record for each product.

    Join that query to the sales table.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    EMAS is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Dec 2015
    Posts
    2
    @Moderator, thanks for the quick response but I was looking for a solution using the most recent purchase price at the moment of the sale and not at the moment of the report.
    Seconly I prefer a solution using a join instead of a subquery (performance).

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    15,767
    Can you post a jpg of your tables and relationships?

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,423
    This will probably require a subquery as well as join.

    Provide sample db for testing. Follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Using and storing "Sale Price"
    By blueman in forum Forms
    Replies: 4
    Last Post: 11-12-2015, 10:10 AM
  2. Replies: 6
    Last Post: 02-28-2015, 11:57 AM
  3. Replies: 4
    Last Post: 04-26-2013, 08:32 AM
  4. Purchase price of asset
    By Ron.Sul in forum Access
    Replies: 4
    Last Post: 09-17-2010, 11:28 PM
  5. Replies: 1
    Last Post: 10-06-2009, 02:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums