0

有人可以帮我吗?有没有办法将以下 IN 子查询重写为连接?任何帮助深表感谢。

SELECT DISTINCT 
    p.processID
    ,p.processName
    ,p.highLevelOrder
FROM 
    tblProcess p
WHERE
    p.highLevel = 1 and processID 
    in (select processID from tblJobCPR, tblJobTracking where tblJobCPR.cprID = tblJobTracking.cprID and tblJobTracking.effectiveEnd >= @processDate)
ORDER BY 
    p.highLevelOrder
4

2 回答 2

1

这应该这样做:

SELECT DISTINCT 
    p.processID
    ,p.processName
    ,p.highLevelOrder
FROM 
    tblProcess p
INNER JOIN tblJobCPR jc
    ON p.processID = jc.processID
INNER JOIN tblJobTracking jt
    ON jc.cprID = jt.cprID
WHERE
    p.highLevel = 1 
    AND jt.effectiveEnd >= @processDate 
ORDER BY 
    p.highLevelOrder
于 2013-08-20T20:06:40.180 回答
0

如果列processIDtblJobCPR表中,请尝试以下方式:

SELECT DISTINCT 
    p.processID
    ,p.processName
    ,p.highLevelOrder
FROM 
    tblProcess p
JOIN tblJobCPR j       on  j.processID = p.processID
JOIN tblJobTracking jt on  j.cprID = jt.cprID 
                       and jt.effectiveEnd >= @processDate
WHERE
    p.highLevel = 1 
ORDER BY 
    p.highLevelOrder
于 2013-08-20T20:06:32.770 回答