日期:2014-05-19  浏览次数:20680 次

[SQL0122] SELECT列表中的列BRANCHID或表达式无效
insert   into   social.grant3(commid,yearfr,monthfr,person,fee,total,opertime,feefrom)   select   c.commid,2007,4,count(r.personid),12.5,count(r.personid)*12.5, '2007-04-09 ',t.branchid   from   sqdta.retire   r,social.paysoc   p,sqdta.community   c,sqdta.street   t   where   r.personid=p.personid   and   p.ispay= '1 '   and   r.commid   =   c.commid   and   c.streetid   =   t.streetid   and   t.branchid   Like   '% '   group   by   c.commid

问题出在t.branchid,但语法没错阿

------解决方案--------------------
你的语句后面加了分组,但是t.branchid 并没有包含在聚合函数中
------解决方案--------------------
insert into social.grant3(commid,yearfr,monthfr,person,fee,total,opertime,feefrom)
try

select c.commid,2007,4,count(r.personid),12.5,count(r.personid)*12.5, '2007-04-09 ',t.branchid
from sqdta.retire r join social.paysoc p on r.personid=p.personid join sqdta.community c on r.commid = c.commid
join sqdta.street t on c.streetid = t.streetid
where p.ispay= '1 ' and t.branchid Like '% ' group by c.commid


sqdta.street有branchid字段吗?