Hello friends, a question has arisen, where even though I have entered various forums, I have not succeeded in healing it, so see if you can give me a "light". I have a main SELECT, and some sub-queries. In one of these sub-queries I need to pass as a parameter in the WHERE clause a column that is present in the main SELECT, something like the one below.
SELECT DISTINCT ID AS NUMERO_CONTRATO,
QUANTIDADE = (SELECT COUNT(PARCELA) FROM
CONTRATO_FINANCEIRO WHERE ID = NUMERO_CONTRATO)
FROM CONTRATO_FINANCEIRO
However, after executing this query, an error is generated because there is no field, and if I pass the ID column itself, it will not return the value of the first query.