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,但语法没错阿

解决方案 »

  1.   

    你的语句后面加了分组,但是t.branchid 并没有包含在聚合函数中
      

  2.   

    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.commidsqdta.street有branchid字段吗?
      

  3.   

    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,t.branchid
      

  4.   

    TRY
    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 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,t.branchid