v=# select sum(case when f < 0 then f end) n, sum(case when f >= 0 then f end) p from s170; n | p ---------+-------- -768.27 | 340.61 (1 row)