Balance 列の where 句を使用して、以下のクエリでデータをフィルター処理する方法。where 条件で Balance を使用すると、["where 句" の列 "Balance" が不明です] というエラーが表示されます。
select *,(it.Total - p.Amount) as Balance
from invoices i
left outer join invoice_items it
on i.ID=it.InvoiceID
left outer join payment p
on p.InvoiceID=it.InvoiceID
where Balance!=0;
また、一致する支払いレコードが見つからない場合は、残高列に null 値を表示する代わりに、invoice_items テーブルの合計値が必要です。