SELECT [Student ID]
,[Course ID]
,[Name]
,max[Marks]
,[Grade]
FROM [CE].[dbo].[GradeCount]
order by [Student ID]
答案 0 :(得分:1)
使用汇总和分组依据
SELECT [Student ID]
,[Course ID]
,[Name]
,max([Marks])
,max([Grade])
FROM [CE].[dbo].[GradeCount]
group by [Student ID] ,[Course ID],[Name]
答案 1 :(得分:0)
只需使用您要使用聚合功能的GROUP BY
字段,例如MAX
,MIN
,AVG
,COUNT
:
SELECT
MAX(course_ID) MaxCourse_ID
, MIN(course_ID) MinCourse_ID
, AVG(course_ID) AvgCourse_ID
, COUNT(course_ID) CountCourse_ID
FROM [CE].[dbo].[GradeCount]
group by course_ID