Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    18

    Question Unanswered: most recent entry

    Hi all,

    I'm looking for a solution for my problem. (aren't we all )If have several 1000 of actions performed every hour / machine --> towards oracle db. What I need do now is to retrieve the record with the most recent date. My record contains several info and one of them is a date field.

    How can I retrieve the most recent record whithout having to sort them first on date an then select the last or first record depending on my sort order.

    Anyone?

    Kind regards
    Geoff

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Perhaps something like this?
    Code:
    SELECT * FROM your_table
    WHERE date_column = (SELECT MAX(date_column) FROM your_table);

  3. #3
    Join Date
    May 2004
    Location
    Dominican Republic
    Posts
    721
    This can probably (and most likely will) select a SET of records, depending on how distributed are the dates on your table (and whether or not dates are unique). Add 'and rownum = 1' to fix that.

Posting Permissions

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