I have the following hypothetical query to the bank:
SELECT dinheiro_na_carteira,
(SELECT sum(despesas_pagas_carteira) FROM DESPESAS WHERE id = X ) as despesas
FROM RECEITAS
WHERE dinheiro_na_carteira - despesas > 0
When trying to do this query it returns the following error:
[Err] 42S22 - [SQL Server] Invalid column name
Can anyone give me a suggestion how can I resolve this situation? I do not even know what to look for.