SQL语句执行卡死,查询不出结果

SQL语句执行卡死,查询不出结果

SELECT    Q03.B0110  ,Q03.E0122, Q03.A0101 , Q03.E0127   ,
sum(Q03.Q0329)  SUM_Q0329,sum(Q03.Q0331) SUM_Q0331,  sum( Q03.Q0329 + Q03.Q0331 )  SUM_JIABAN,sum(Q03.Q0317)  SUM_Q0317 , sum(isnull(Q03.Q0319,0))  SUM_Q0319,sum(Q03.Q0305) SUM_Q0305,sum(isnull(Q03.Q0301,0))  SUM_Q0301,sum(isnull(Q03.Q0303,0)) SUM_Q0303,sum(Q03.Q0307)  SUM_Q0307,sum(Q03.Q0309) SUM_Q0309, sum(Q03.Q0311) SUM_Q0311,sum(Q03.Q03ZE) SUM_Q03ZE,sum( Q03.Q03Z8 ) SUM_Q03Z8,isnull(UsrA01.C0181,RetA01.C0181)     renyuanleibie,isnull(UsrA01.H01SV , RetA01.H01SV)    H01SV,
(case when  VO.CODEITEMDESC is null  then   organization.codeitemdesc  
ELSE  VO.CODEITEMDESC END ) AS CODEITEMDESC ,  
organization.codeitemdesc  CENTERDESC,VO.DEPARTMENT ,
(case when  VO.DEPARTMENTDESC is null  AND VO.CODEITEMDESC   IS NOT NULL  then  VO.CODEITEMDESC   
when  VO.DEPARTMENTDESC  is null  AND  VO.CODEITEMDESC IS NULL  then organization.codeitemdesc 
ELSE VO.DEPARTMENTDESC END ) as DEPARTMENTDESC  ,  VO.FULLNAME FROM   dbo.Q03 Q03  
LEFT JOIN  dbo.UsrA01 UsrA01     ON   Q03.E0127 =  UsrA01.E0127 
LEFT JOIN  dbo.RetA01 RetA01    ON   Q03.E0127 = RetA01.E0127 
LEFT JOIN  dbo.VIEW_ORGANIZATION_BELONG VO   ON  Q03.E0122=   VO.CODEITEMID
LEFT JOIN dbo.organization organization ON  Q03.B0110 = organization.codeitemid  WHERE    Q03.Q03Z0  BETWEEN  开始日期 AND  结束日期 GROUP BY  Q03.B0110 , Q03.E0122 , Q03.A0101 , Q03.E0127 ,isnull(UsrA01.C0181,RetA01.C0181) ,isnull(UsrA01.H01SV , RetA01.H01SV) , VO.CODEITEMDESC , organization.codeitemdesc ,VO.DEPARTMENT  ,VO.DEPARTMENTDESC  , VO.FULLNAME 
sql

2个回答

连表太多,数据量大,会比较慢,你先去掉连表,再一个一个加,看看是哪个拖累了性能。

分开来写,数据表关系太复杂还有不要出现杠杆现象

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问