首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

sql2000中一个简单的关于group by语句的有关问题

2012-01-07 
sql2000中一个简单的关于group by语句的问题selectstudent_no,student_agefromtb_student_tempgroupbystud

sql2000中一个简单的关于group by语句的问题
select   student_no,student_age
from   tb_student_temp
group   by   student_no
提示
tb_student_temp.student_age '   在选择列表中无效,因为该列既不包含在聚合函数中,也不包含在   GROUP   BY   子句中  

是不是select后面有什么字段   group   by也要有几个字段???  
比如我要查询的结果显示很多个字段,按某一个字段分组该怎么写?

[解决办法]
select student_no,student_age
from tb_student_temp
group by student_no,student_age
[解决办法]
select student_no,max(student_age) student_age
from tb_student_temp
group by student_no
[解决办法]
select 后面的字段列表中除了包括group by后面字段外,其余的都应该是聚合函数
[解决办法]
多谢谢语句 就知道了

热点排行
Bad Request.