I am having problems with a left join SQL query but can\'t see why it isn\'t working. I have 3 tables: customers, purchases and payments, and i\'m trying to select customers who
Unfortunately you can't reference an alias on the same "level" where it's defined.
You need to wrap everything into a derived table:
select * from ( ) t where balance > 0