Results 1 to 3 of 3

Thread: How to Select max record in Oracle

  1. #1
    Join Date
    Dec 2008
    Posts
    69

    How to Select max record in Oracle

    How to find the Max records from the available records, I have oracle database and I wanted to write statement that returns the most recent revision date with the set of Records.. If anyone knows about this please let me know.

  2. #2
    Join Date
    Feb 2006
    Posts
    172

    Re: How to Select max record in Oracle

    Select the max of your date column, and use a where clause about that column only for date less than today.

    Code:
    select a.sal 
     from emp a
      where 1=(select distinct(count(b.sal))
                 from emp b
                   where a.sal<=b.sal);
    
    for second max
    
    select a.sal 
     from emp a
      where 2=(select distinct(count(b.sal))
                 from emp b
                   where a.sal<=b.sal)
    You can't group by GRP and also select ID. This doesn't make sense, because (to the DB) you might have two IDs with the same maximum DATE and GRP.

  3. #3
    Join Date
    Dec 2008
    Posts
    161

    Re: How to Select max record in Oracle

    The number of factors that influences performance are so great that the best you could do is test both alternatives. you may use this query to join it with another query containing the IDs, If the response time is not good enough, then you must send details like:

    SELECT MAX(ID) as maxid, GRP, MAX(DATE) AS max_date
    FROM table
    GROUP BY GRP

Similar Threads

  1. Replies: 4
    Last Post: 14-05-2010, 12:16 AM
  2. Select unique columns from a record set
    By Madhuchhanda in forum Software Development
    Replies: 6
    Last Post: 12-05-2010, 11:31 PM
  3. SELECT UNIQUE and SELECT DISTINCT
    By TAARIQ in forum Software Development
    Replies: 3
    Last Post: 03-06-2009, 10:00 PM
  4. Windows DNS server - force A record to update PTR record
    By Peter Cumming in forum Windows Server Help
    Replies: 1
    Last Post: 27-05-2006, 07:00 PM

Tags for this Thread

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
  •  
Page generated in 1,714,202,183.10541 seconds with 17 queries