writing a query to get the second highest value in atable by using select statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • konaravikumar
    New Member
    • Sep 2007
    • 1

    writing a query to get the second highest value in atable by using select statement

    writing a query to get the second highest value in atable by using select statement
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    As you have posted a question in the articles section it is being moved to Oracle Forum.

    MODERATOR.

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      Originally posted by konaravikumar
      writing a query to get the second highest value in atable by using select statement
      Kindly post the query that you have tried to solve this.

      Comment

      • arulkumara
        New Member
        • Aug 2007
        • 15

        #4
        Originally posted by konaravikumar
        writing a query to get the second highest value in atable by using select statement
        Hi
        try this

        select level,max(salar y) from emp1
        where level=2
        connect by prior salary>salary
        group by level;

        here salary->column

        Comment

        • arulkumara
          New Member
          • Aug 2007
          • 15

          #5
          Originally posted by konaravikumar
          writing a query to get the second highest value in atable by using select statement
          Hi
          try this

          select level,max(salar y) from emp1
          where level=2
          connect by prior salary>salary
          group by level;

          here salary->column name

          Comment

          • amitpatel66
            Recognized Expert Top Contributor
            • Mar 2007
            • 2358

            #6
            Originally posted by arulkumara
            Hi
            try this

            select level,max(salar y) from emp1
            where level=2
            connect by prior salary>salary
            group by level;

            here salary->column name
            Try below Query:

            [code=oracle]
            SELECT min(e.salary) FROM emp e WHERE 2 > (SELECT COUNT(*) FROM emp WHERE salary > e.salary)
            [/code]

            Comment

            Working...