当我将日期设置为一个月以上时,此sql服务器查询会超时。请帮忙。
我迷路了。大声笑
`SELECT
LaborDtl.JobNum,
LaborDtl.ClockInDate,
LaborDtl.OprSeq,
EmpBasic.Name,
(LaborDtl.LaborHrs) as [TotalHrs],
-- (JobOper.EstSetHours + JobOper.EstProdHours),
cast((JobOper.EstSetHours + JobOper.EstProdHours) /
SUM(COUNT(EmpBasic.Name)) OVER (partition by LaborDtl.OprSeq)as
decimal(10,3)) as [TotEstHrs],
LaborDtl.ResourceGrpID
FROM Erp.LaborDtl
left outer JOIN Erp.JobOper ON
JobOper.JobNum = LaborDtl.JobNum
and JobOper.OprSeq = LaborDtl.OprSeq
JOIN Erp.EmpBasic ON
EmpBasic.EmpID = LaborDtl.EmployeeNum
WHERE LaborDtl.Complete = '1'
AND LaborDtl.ClockInDate >= '2019-1-1'
-- and LaborDtl.ResourceGrpID = '5-XM-C'
-- AND LaborDtl.JobNum = 'pa16742'
GROUP BY
LaborDtl.JobNum,
LaborDtl.OprSeq,
LaborDtl.ClockInDate,
EmpBasic.Name,
LaborDtl.LaborHrs,
JobOper.EstSetHours,
JobOper.EstProdHours,
LaborDtl.EmployeeNum,
LaborDtl.ResourceGrpID`
执行超时