+ Reply to Thread
Results 1 to 2 of 2

Thread: Finding latest date with query

  1. #1
    Registered User
    Join Date
    07-16-2007
    Posts
    38

    Finding latest date with query

    I need to pull only the records with the latest date into Excel from Access. As a simplified example, let's say the Access database has two tables:

    Table T1 is price history with fields PartNum, PriceDate, Price. For each PartNum, there are multiple dates (PriceDate) and associated prices (Price).
    example:
    P1, 1/1/10, $1.00
    P1, 2/1/10, $2.00
    P1, 3/1/10, $3.00
    P2, 1/1/10, $4.00
    P2, 2/1/10, $3.00
    P3, 1/1/10, $1.00

    Table T2 has cost data and has fields PartNum, Cost.
    example:
    P1, $0.50
    P2, $0.75

    Using a query executed from within Excel, I need to pull into Excel from Access all PartNum's where the PartNum is in both tables, the latest PriceDate and Price for each PartNum, and the Cost for each PartNum.
    results example:
    P1, 3/1/10, $3.00, $0.50
    P2, 2/1/10, $3.00, $0.75

    I've tried this but it doesn't work.

    Select T1.PartNum, max(T1.PriceDate), T1.Price, T2.PartNum, T2.Cost
    From T1, T2
    Where T1.PartNum = T2.PartNum

    I'd appreciate any help here.
    Last edited by sumdumgai; 09-27-2010 at 07:23 PM.

  2. #2
    Valued Forum Contributor alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Lake County, Illinois
    MS-Off Ver
    MS Office 2010, 2007 and 2002
    Posts
    1,161

    Re: Finding latest date with query

    I got this to work in Access by using two queries. Attached is the dB I created and the two queries. You can then export the second query to excel, or you can adapt your excel query to mirror the same one in Access. Good luck.

    Alan
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0