【发布时间】:2021-11-05 22:55:33
【问题描述】:
这是我的学生桌。我想显示在宿舍中拥有 max(parent_inc) 的学生的宿舍、rollno、parent_inc。当我尝试这个命令时 -
select hostel, rollno, max(parent_inc) from students group by hostel;
出现错误 -
column "students.rollno" must appear in the GROUP BY clause or be used in an aggregate function
select hostel, rollno, max(parent_inc) from students group b...
如何正确获取?
如果不选择 rollno 字段,它可以正常工作。
【问题讨论】:
-
您需要将测试数据发布为格式化文本 - 不是图像。请参阅Why no images 或更好地创建fiddle。
标签: postgresql greatest-n-per-group