这是我的查询,
**select
students.st_id,students.st_group,
rank() over (partition by students.st_group order by avg(grades.g_grade) desc ) as ranking ,
lead(avg(grades.g_grade), 1, 0) OVER (PARTITION BY students.st_group ORDER BY avg(grades.g_grade) DESC NULLS LAST) DifferencebetweenHigheraverage,
avg(grades.g_grade)
from grades left join students on grades.g_student=students.st_id
group by students.st_id,students.st_group
having students.st_group in (1,2,3);**
请帮助.......
答案 0 :(得分:0)
如果在表STUDENT_GRADES中,我有属性
选择查询以获得学生与其小组中最高成绩的区别
with MAXGRADES as (select ST_GROUP, max(ST_GRADE) as MAX from STUDENT_GRADES)
select ST_ID, ST_GRADE - MAX as DIFF from STUDENT_GRADES inner join MAXGRADES using(ST_GROUP)