Home » SQL & PL/SQL » SQL & PL/SQL » rank (Developer 6i, Databse 11G R2,window 7 ultimate)
rank [message #634121] Wed, 04 March 2015 11:34 Go to next message
kilimanjaro
Messages: 151
Registered: May 2009
Location: Tanzania
Senior Member
Hello,

The below query fetches students and their correspondent ranking in terms of max achieved and it does so as I wanted. The problem is I want to fetch specific student and the rank .It doesn't give me the results even when using the parameter =:STUDENT_NUMBER. In all scenarios it returns position(PS) = 1.

select distinct student_name, event_number ,MAX_ATTAINED,grade,milestone,DENSE_RANK() OVER (PARTITION BY event_number ORDER BY MAX_ATTAINED DESC ) PS from examination3
--where student_name=:STUDENT_NUMBER)

Thank you.
Re: rank [message #634125 is a reply to message #634121] Wed, 04 March 2015 12:52 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
Your question is not clear, but it remotely resembles a question that I would suggest to use a SELECT of a resultset.
Re: rank [message #634128 is a reply to message #634121] Wed, 04 March 2015 13:13 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

To make the question clearer, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Re: rank [message #634131 is a reply to message #634128] Wed, 04 March 2015 13:41 Go to previous messageGo to next message
kilimanjaro
Messages: 151
Registered: May 2009
Location: Tanzania
Senior Member
Thank you all for quick reply.This is the scenario.

I have an examination table with,three columns: max_achieved,class_code,student_number.
Now I want to rank students based on the max_achieved and class code for individual reports. I hope this is clear.

Thank you all for assistance.
Re: rank [message #634133 is a reply to message #634131] Wed, 04 March 2015 13:53 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Where is the test case?

Re: rank [message #634152 is a reply to message #634131] Wed, 04 March 2015 15:29 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
What does this have to do with the original question?
Re: rank [message #634792 is a reply to message #634121] Mon, 16 March 2015 04:26 Go to previous messageGo to next message
sujith1024
Messages: 1
Registered: March 2015
Junior Member
select student_name,student_number,class_code,max_achieved,DENSE_RANK() OVER (PARTITION BY class_code ORDER BY max_achieved DESC ) as rnk
from examination;
Re: rank [message #634794 is a reply to message #634792] Mon, 16 March 2015 05:04 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

@sujith1024,

Welcome to the forum.
Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.

Re: rank [message #634848 is a reply to message #634794] Mon, 16 March 2015 15:22 Go to previous message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
select student_name,student_number,class_code,max_achieved,rnk
from
(select student_name,student_number,class_code,max_achieved,DENSE_RANK() OVER (PARTITION BY class_code ORDER BY max_achieved DESC ) as rnk
from examination)
where student_number = 123;
Previous Topic: Why "SQL command not properly ended" error on one and not on the other?
Next Topic: create dynamic view based on metadata
Goto Forum:
  


Current Time: Fri Apr 19 20:23:24 CDT 2024