尝试选择其他属性时出错ERROR ORA-00937

时间:2013-10-29 21:26:58

标签: sql oracle sqlplus

我正在努力预测专业学生的平均GPA水平。

如果我不选择major并将其遗漏,那么它就有效。

这就是我所拥有的:

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

我的错误:ORA-00937:不是单组组功能

1 个答案:

答案 0 :(得分: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
)