I have two tables
Master
Detail
In the Master & Detail table
I get the SUM of Amount Applied in Detail and subtract it from Initial Amount in Master and display in “REMAIN”
select m.ID, m.Init_Amnt, m.Cur_Amnt, max(m.Init_Amnt) - sum(d.Amnt_appl) REMAIN
from AMASTER m
left join ADETAIL D on m.ID = d.Master_ID
group by m.ID, m.Init_Amnt, m.Cur_Amnt
Is there a way to show only those where the remain in not null OR remain > 0.00
Because this is a filter on an aggregated result, you need a HAVING clause. Depending on your flavour of SQL, something like this:
In this, 1 is just a “magic number” to meet the
> 0condition in the case of a null.