• Please use the below query.

    select party_code,sum(inst_amt) as Total_instamt,sum(paid_amt) as paid from @table1 where paid_date is null or paid_date <'2012-07-23'

    group by party_code[/b]