I've been away from SQL for quite a while and am working on a DB project now. I have the following code I am trying to only get Tenants who have a negative balance.
Code:
select sum(finance.trans_amount) as balance, tenants.last, tenants.first from
finance join tenants on (finance.trans_tenant = tenants.tenant_id)
group by finance.trans_tenant
order by balance;
I have tried to put a "where balance < 0" in the statement but get an error about balance not being a column. Without the where clause like above everything works fine. What do I need to do to only retrieve tenants with negative balances.