oracle查询特殊用法

学号 学生姓名 课程名称 成绩(只显示每科最高分)
oracle 里可以这样用:
select a.studentid as "学  号",studentname "学生姓名",
subjectname "课程名称",mark "成  绩"
from student a , subject b , grade c
where a.studentid = c.studentid
and b.subjectid = c.subjectid
and (b.subjectid,mark) in(select subjectid,max(mark)  from grade group by subjectid)
;

/**************************************************************************/

alter table grade add (ord number(3));
update grade a set ord = (
       select count(*)+1 from grade where a.mark > mark
)

alter table grade add (ord2 number(3));
update grade a set ord2 = (
       select count(*)+1 from grade where a.mark < mark
)

select * from grade;

原文地址:https://www.cnblogs.com/pan11jing/p/1545015.html