Reputation: 1
Having this data:
I am running this code:
SELECT student_info.student_name,student_info.department,student_info.marks,
rank() over (order by student_info.marks desc) score from student_info ;
and getting:
I want first two records alone with rank with out using rownum
Upvotes: 0
Views: 46
Reputation: 74
Can you try this please, I think this is what you need
SELECT student_name, department, marks, score
FROM (SELECT s.*, RANK() OVER (ORDER BY marks DESC) AS score
FROM student_info s)
WHERE score = 1
Upvotes: 2