Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2002
    Posts
    30

    Unanswered: How to select only newer data

    Sorry, it seems I got a lot of trouble..
    I need to obtain the latest data for my database i.e. I have this table

    Date, ID, Price
    1 Nov 2002, Item 1, 20
    15 Nov 2002, Item 1, 23
    10 Dec 2002, Item 2, 25
    20 Nov 2002, Item 3, 10
    22 Nov 2002, Item 3, 8

    I need to compile into this table
    Date, ID, Price
    15 Nov 2002, Item 1, 23
    10 Dec 2002, Item 2, 25
    22 Nov 2002, Item 3, 8

    Thank you

  2. #2
    Join Date
    Dec 2002
    Posts
    9
    Not too sure what you are trying to achieve but you might like to try creating an index that is sorted based on your date value in a decending format and creating a top 10 or top whatever select statement that is based on date. This along with the index should provide you with the latest data.

    Y.

  3. #3
    Join Date
    Dec 2002
    Location
    Czech Republic
    Posts
    249
    /*
    I expect, that there is PK on Price(ID,Date) to avoid
    duplicate prices at the same time.
    */

    select p.ID,XXX."Date",p.Price
    from Price p
    join (
    select ID,"Date"=max("Date")
    from Price
    group by ID
    ) XXX on p.ID=XXX.ID and p."Date"=XXX."Date"
    Last edited by ispaleny; 12-16-02 at 10:18.

  4. #4
    Join Date
    Sep 2002
    Posts
    30
    thx ispaleny... that do the trick..
    yorkie: I need that to check for the latest price.

Posting Permissions

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