1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Oracle Query

Discussion in 'General' started by Shruthic, Jul 22, 2013.

  1. Shruthic

    Shruthic Active Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    55
    I have a table which is in the following format,

    Student No|| Score
    Stud 1 || 98
    Stud 1 || 80
    Stud 1 || 70
    Stud 2 || 90
    Stud 2 || 70

    I require a query to display a result in the following format
    Student No ||Top Score
    Stud 1 || Top1
    Stud 1 || Top2
    Stud 1 || Top3
    Stud 2 || Top1
    Stud 2 || Top2

    Could any one please provide me with a query to get the above result
     
  2. sambuduk

    sambuduk Forum Advisor

    Messages:
    242
    Likes Received:
    73
    Trophy Points:
    455
    Location:
    Hyderabad , Telangana
    Hi Shruthic,

    Student No and Score are seperate columns right?

    If both are separate columns Try with the below query .


    select stuno
    ,Score
    ,'TOP ' ||RANK() OVER (PARTITION BY stuno ORDER BY score desc) "Top Score"
    from xx_st


    Regards
    Sambasiva Reddy.K
     
    fahad08 likes this.
  3. Shruthic

    Shruthic Active Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    55
    Thanks for the reply.. It worked for me!!!