我在另一个子查询中有一个带有子查询的查询。因此,底层子查询无法识别顶层子查询中的字段。我该如何解决?
SELECT codigo, descricao
FROM statusplano sp, previsao pr
WHERE sp.codigo = pr.status
AND pr.plano = 13
AND sp.codigo = (SELECT codigo FROM statusplano sp1 WHERE ordem = (SELECT max(sp2.ordem) FROM statusplano sp2 WHERE sp2.codigo = pr.codigo AND pr.dataPrevista <= now()))
提前致谢。