Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003
    Posts
    2

    Unanswered: SQL Select problem

    Dear experts:
    i have a table call productpricehistory which consists three columns
    productID,PublishDate,Price
    there are many records with same productID but different PublishDate
    so how to get a list with the latest publishdate for each product
    thank you

  2. #2
    Join Date
    Jan 2003
    Posts
    2
    plus:
    i also need a list with the latest price for each product

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    select productID, max(PublishDate)
    from productpricehistory
    group by productID
    order by productID

    select productID, Price
    from productpricehistory X
    where PublishDate
    = (select max(PublishDate)
    from productpricehistory
    where productID = X.productID)
    order by productID

    homework?


    rudy

Posting Permissions

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