我有一个sql查询:
SELECT
count(*) as count
FROM
USERS.Names p1
WHERE
p1.rowid IN (
SELECT p2.rowid
FROM USERS.Names p2
WHERE
p2.Id = p1.Id AND p2.status = p1.Status
AND p2.DateTo = (SELECT max(p3.dateTo)
FROM USERS.Names p3
WHERE p3.entityid = p1.Id
AND p3.status = p1.Status
AND p3.Code = p2.Code)
)
AND p1.Status = 1
AND p1.Id >= 12
AND p1.Id < 31308;
с我移除嵌套的 SELECT
并用 JOIN
什么?这个请求已经运行了很长时间
2条答案
按热度按时间cfh9epnr1#
试试这个:
2mbi3lxu2#
以下可能是您要寻找的: