select student_no,student_age
from tb_student_temp
group by student_no
提示
tb_student_temp.student_age' 在选择列表中无效,因为该列既不包含在聚合函数中,也不包含在 GROUP BY 子句中 是不是select后面有什么字段 group by也要有几个字段???
比如我要查询的结果显示很多个字段,按某一个字段分组该怎么写?
from tb_student_temp
group by student_no
提示
tb_student_temp.student_age' 在选择列表中无效,因为该列既不包含在聚合函数中,也不包含在 GROUP BY 子句中 是不是select后面有什么字段 group by也要有几个字段???
比如我要查询的结果显示很多个字段,按某一个字段分组该怎么写?
from tb_student_temp
group by student_no,student_age
from tb_student_temp t
where exists (select 1 from tb_student_temp where t.student_no=student_no and t.student_age>t.student_age)
from tb_student_temp
group by student_no
除非是函数里面的字段,那分组后面就可以没有函数里面的字段????????
是这样的么???
group by 的字段可有可无
select sum(student_age)
from tb_student_temp
group by student_no