课程表:courseId,courseName,导师
学生表:studentId,studentName
标记表:marksId,studentId,courseId,marks
如果需要更多信息请注释
< \&BR GT;
CREATE VIEW maxmarks
AS
SELECT b.studentName,courseId from [dbo].[zz_16_Marks_tbl] a,[dbo].[zz_16_Student_tbl] b
WHERE a.studentId=b.studentId AND marks in(
SELECT MAX(marks),courseId FROM [dbo].[zz_16_Marks_tbl] GROUP BY courseId)
答案 0 :(得分:0)
CREATE VIEW maxmarks
AS
WITH CTE AS (SELECT MAX(marks),courseId FROM [dbo].[zz_16_Marks_tbl] GROUP BY courseId )
SELECT b.studentName,a.courseId
from [dbo].[zz_16_Marks_tbl] a
INNER JOIN [dbo].[zz_16_Student_tbl] b ON a.studentId=b.studentId
INNER JOIN CTE c ON a.courseId =c.courseId and a.marks=b.marks