这是我的专栏
create table exam_details(
Stud_id varchar2(50),
Stud_course_id Number,
Stud_div char,
Stud_Sub_id Number,
Stud_Marks Number,
Sub_total_Marks Number,
Exam_id Number,
Exam_date Date
);
数据库的内容是
insert into exam_details values ('1A1',1,'A',1,55,100,1,'2-jan-2015');
insert into exam_details values ('1A1',1,'A',2,65,100,1,'3-jan-2015');
insert into exam_details values ('1A1',1,'A',3,72,100,1,'5-jan-2015');
insert into exam_details values ('1B1',1,'B',1,45,100,1,'2-jan-2015');
insert into exam_details values ('1B1',1,'B',2,65,100,1,'3-jan-2015');
insert into exam_details values ('1B1',1,'B',3,58,100,1,'5-jan-2015');
insert into exam_details values ('2A1',2,'A',1,75,100,1,'2-jan-2015');
insert into exam_details values ('2A1',2,'A',2,65,100,1,'3-jan-2015');
insert into exam_details values ('2A1',2,'A',3,82,100,1,'5-jan-2015');
我已经尝试过,但我只得到结果
select stud_id,
RANK() OVER(ORDER BY stud_marks DESC) AS "Rank"
from exam_details;
也许这个:
select stud_id, Stud_div,
RANK() OVER(ORDER BY stud_marks DESC) AS Rank_all,
RANK() OVER(PARTITION BY Stud_div ORDER BY stud_marks DESC) AS Rank_div
from exam_details;