set autocommit on \p\g drop table if exists testsum;\p\g create table testsum ( batch_no integer not null default 0, seq integer not null default 0, source_amount float not null default 0 ) ;\p\g insert into testsum values ( 123, 1, 672.00), ( 123, 2, 6000.96), ( 123, 3, 3600.00), ( 123, 4, 3251.25), ( 123, 5, 3229.80), ( 123, 6, 4827.15), ( 123, 7, 4016.25), ( 123, 8, 1056.00), ( 123, 9, 1943.10), ( 123, 10, -28596.50) \p\g select * from testsum ;p\g select batch_no, count(*), sum(source_amount) from testsum group by batch_no having abs(sum(source_amount)) >= 0.01 ;\p\g select batch_no, count(*), sum(source_amount) from testsum group by batch_no having abs(sum(source_amount)) >= 0.005 ;\p\g select batch_no, count(*), sum(source_amount) from testsum group by batch_no ;\p\g