消息 156,级别 15,状态 1,第 4 行
关键字 'group' 附近有语法错误。

解决方案 »

  1.   

    update a
       set C213I=b.s
      from a,
           (select id, sum( isnull(C211I,0) ) s
              from 部门
           group by a.id
           ) b
     where 部门id=b.id
      

  2.   

    你为什么要group by a.id?
      

  3.   

    case when 
      [计划出勤小时] >10 then 
        case when 
          [计划出勤小时] <10 and  [计划出勤小时]>3 then
             case when 
                [计划出勤小时] >3 then 0.7
                 else 1
              end
         else 0.5
         end
     else 0
    end
    这个语法没有错误,但计算没有数值。case when   [计划出勤小时] >10 then 0
    when   [计划出勤小时] =10 and  [计划出勤小时] <3 then 0.7
    when ******
    end 
    可以计算有数据是什么原因
      

  4.   

    update a
    set  C213I=sum( isnull(C211I,0) ) from 部门  join a 
    where 部门id=a.id
    group by a.id
      

  5.   

    update a
    set  C213I=sum( isnull(C211I,0) ) from 部门  join a 
    on 部门id=a.id
    group by a.id 写错了 不好意思 应该是on 
      

  6.   

    case when [计划出勤小时] >10 then 
        -- 这时候 > 10
        case when [计划出勤小时] <10 and  [计划出勤小时]>3 then
             -- 永远进不来
             case when 
                [计划出勤小时] >3 then 0.7
                 else 1
              end
        else
            -- 所以 > 10 时返回这个
            0.5
        end
    else
        -- 所以 <= 10 时返回这个
        0
    end
      

  7.   

    update a
       set C213I=b.s
      from a,
           (select id, sum( isnull(C211I,0) ) s
              from 部门
           group by a.id
           ) b
     where 部门id=b.id