select ProjectActionNode.StatusID from ProjectActionNode where( ProjectActionNode.ProjectID=47 and ProjectActionNode.ActionNode=
(select c."ID" from ActionNode c where 
     (c.PreStatusID=(select d.StatusID from Project d where d."ID"=47 )
      and c.ID in(select ActionNodeID from ProjectActionNode where ProjectActionNode.StatusID=2)
      and c.ActionID in 
              ( select a.ActionID from FlowNode a where( a."ID" in 
                                                       (select b.FlowNodeID from ProjectFlowNode b where b.ProjectID=47) and  SubjectRoleID=4)))  
                                                                group by c."ID")
group by ProjectActionNode.StatusID
服务器: 消息 156,级别 15,状态 1,行 9
在关键字 'group' 附近有语法错误。
这是咋回事呀!??那位兄弟受累给看看!!!:)

解决方案 »

  1.   

    朋友,以后写Sql 得注意格式了。
    否则遇到这种多层的Sql肯定挂。
      

  2.   

    select ProjectActionNode.StatusID 
    from ProjectActionNode 
    where ProjectActionNode.ProjectID=47 and ProjectActionNode.ActionNode=
    (
    select c."ID" from ActionNode c 
    where 
    (c.PreStatusID=(select d.StatusID from Project d where d."ID"=47 )
        and c.ID in(select ActionNodeID from ProjectActionNode where ProjectActionNode.StatusID=2)
           and c.ActionID in 
                (select a.ActionID from FlowNode a 
    where
    ( a."ID" in (select b.FlowNodeID from ProjectFlowNode b where b.ProjectID=47) 
    and  SubjectRoleID=4
    )
    )
    )  
        group by c."ID"
    )
    group by ProjectActionNode.StatusID
      

  3.   

    简单的说:把第一个Where后面的"("删掉就好了。
      

  4.   

    给我举个写多层SQL的正规的格式吧??
    让俺也提高以下!!!:)
      

  5.   

    按模块虽仅就可以了:select ProjectActionNode.StatusID 
       from ProjectActionNode 
       where ProjectActionNode.ProjectID=47 and ProjectActionNode.ActionNode=
       (
       select c."ID" from ActionNode c 
          where 
          (c.PreStatusID=(select d.StatusID from Project d where d."ID"=47 )
          and c.ID in(select ActionNodeID from ProjectActionNode where ProjectActionNode.StatusID=2)
          and c.ActionID in 
             (select a.ActionID from FlowNode a 
                where
                ( a."ID" in (select b.FlowNodeID from ProjectFlowNode b where b.ProjectID=47) 
                and  SubjectRoleID=4
                )
             )
          )  
        group by c."ID"
       )
    group by ProjectActionNode.StatusID