首先要找出最高课程的分数,然后再根据分数,找出最高的学号。楼上的两位,语法错误。
CREATE VIEW V单科最高分 AS
select a.学号, b.姓名, a.课程号, c.课程名, a.成绩
(select a.* from xs_kc a, (select 课程号, max(成绩) 成绩 from xs_kc group by 课程号) b
where a.课程号 = b.课程号 and a.成绩=b.成绩) a, xsqk b, kc c
where a.学号 = b.学号 and b.课程号 = c.课程号
CREATE VIEW V单科最高分
AS
BEGIN
SELECT xs_kc.学号,xsqk.姓名,xs_kc.课程号,MAX(xs_kc.成绩) AS 成绩
FROM xs_kc ON xs_kc.学号 = xsqk.学号
GROUP BY xs_kc.课程号
END
CREATE VIEW 'V单科最高分'
AS
select b.学号,b.姓名,a.课程号,a.成绩
from (select 学号,课程号,max(成绩) as 成绩,学分 from xs_kc group by 课程号) a,
xsqk b
where a.学号=b.学号