错在哪里求高手解答
sqlserver吧
全部回复
仅看楼主
level 3
MLQQ闯天涯 楼主
2015年04月14日 17点04分 1
level 1
看不清
2015年04月22日 03点04分 2
level 1
问题错在含有group by 从句的SELECT之后的列,要么是group by the 列, 要么就要进行聚合运算, 所以你的语句可以改成以下
create view View_Class(Class_Count,Class_name,depar_name)
as
select COUNT(Stu_id),Class_name,Depar_name
from Student,Class,Department
where student.class_id = class.class_id and class.depar_id = department.depar_id
group by Student.class_id,class.class_name,department.depar_name
或者
create view View_Class(Class_Count,Class_name,depar_name)
as
select COUNT(Stu_id),MAX(Class_name),MAX(Depar_name)
from Student,Class,Department
where student.class_id = class.class_id and class.depar_id = department.depar_id
group by Student.class_id
2015年04月28日 13点04分 3
level 2
看不清
2015年04月29日 11点04分 4
1