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

这句查询错哪了

2012-10-18 
这句查询哪里错了select InnerID ,PositionX, PositionY, PositionZ, RotationX, RotationY, RotationZ, S

这句查询哪里错了
select InnerID ,PositionX, PositionY, PositionZ, RotationX, RotationY, RotationZ, SizeX, SizeY, SizeZ, ComponentType, (a1.InnerID,sum (a1.ComponentValues) as Diameter,sum(a2.ComponentValues) as cuttingLength)
from ((AnormalComponentInfo a1, a2 inner join ComponentInfo c on a1.InnerID = c.InnerID )inner join Template t on c.TemplateID = t.TemplateID ) 
where c.ParentComponentID='A132D0AB-8A40-4204-B48B-124EF0B98A64' and a1.InnerID = a2.InnerID and a1.ComponentAttribute = 'Diameter' and a2.ComponentAttribute = 'cuttingLength'
group by a1.InnerID

[解决办法]

SQL code
select InnerID ,PositionX, PositionY, PositionZ, RotationX, RotationY, RotationZ, SizeX, SizeY, SizeZ, ComponentType,  --这些列都没有指定表(a1.InnerID,sum (a1.ComponentValues) as Diameter,sum(a2.ComponentValues) as cuttingLength    )  from ((AnormalComponentInfo a1, a2            inner join ComponentInfo c on a1.InnerID = c.InnerID )inner join Template t on c.TemplateID = t.TemplateID )  where c.ParentComponentID='A132D0AB-8A40-4204-B48B-124EF0B98A64' and a1.InnerID = a2.InnerID and a1.ComponentAttribute = 'Diameter' and a2.ComponentAttribute = 'cuttingLength'group by a1.InnerID       --聚合列于获取的信息列不匹配
[解决办法]
所有未使用聚合函数的列必须出现在group by 后面。也就是你select的这些列PositionX, PositionY, PositionZ, RotationX, RotationY, RotationZ, SizeX, SizeY, SizeZ, ComponentType都必须出现在group by 后面

热点排行