0

我正在尝试按专业预测学生的最高平均 GPA。

如果我不选择major并忽略它,它会起作用。

这就是我所拥有的:

SELECT  MAX(avg_gpa), major
FROM    (SELECT major, AVG(gpa) AS avg_gpa
        FROM Student
        GROUP BY  major);

我的错误:ORA-00937: not a single-group group function

4

1 回答 1

1
SELECT  
  MAX(avg_gpa) as max_avg_gpa, 
  min(major) keep (dense_rank first order by avg_gpa desc) as best_major
FROM (
  SELECT 
    major, 
    AVG(gpa) AS avg_gpa
  FROM Student
  GROUP BY  major
)
于 2013-10-29T21:41:19.297 回答