Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    34

    Unanswered: Price for most recent date

    I have a table called tblModelPrices, with the following fields: CommunityID, ModelID, Date, Price.

    I need an SQL statement that will return the most recent price for any given CommunityID/ModelID combination.

    Any tips?

  2. #2
    Join Date
    May 2003
    Posts
    26

    Re: Price for most recent date

    Try using the following SQL statement which contains a subquery.


    SELECT tblModelPrices.CommunityID, tblModelPrices.ModelID, tblModelPrices.Date, tblModelPrices.Price
    FROM tblModelPrices
    GROUP BY tblModelPrices.CommunityID, tblModelPrices.ModelID, tblModelPrices.Date, tblModelPrices.Price
    HAVING (((tblModelPrices.Date)=(SELECT Max(tblModelPrices.Date) AS MaxOfDate FROM tblModelPrices GROUP BY tblModelPrices.CommunityID, tblModelPrices.ModelID;)))
    ORDER BY tblModelPrices.CommunityID, tblModelPrices.ModelID;


    Originally posted by Ewin
    I have a table called tblModelPrices, with the following fields: CommunityID, ModelID, Date, Price.

    I need an SQL statement that will return the most recent price for any given CommunityID/ModelID combination.

    Any tips?
    Last edited by ramonas; 11-03-03 at 14:33.

  3. #3
    Join Date
    Oct 2003
    Posts
    34
    Thanks!

Posting Permissions

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