null value in queries to default in zero - Mailing list pgsql-general

From Dorward Villaruz
Subject null value in queries to default in zero
Date
Msg-id 000b01c28a52$64cbe2b0$043d1cac@speed
Whole thread Raw
Responses Re: null value in queries to default in zero
List pgsql-general
i have a table test1 as create test1(f1 integer, f2 integer);

select * from test1 will return
  f1 | f2
  --+--
  1  | 2
  2  | 3
  3  | 4
  4  | 5
  5  | 6
(5 rows)

select to_char(avg(f1),'FM999999.99') from test will yield

to_char
--------
3
(1 row)


select to_char(avg(f1),'FM999999.99') from test where f2 <= 5 will yield

to_char
--------
2.5
(1 row)

select to_char(avg(f1),'FM999999.99') from test where f2 > 7 will yield
to_char
--------

(1 row)

is their a way to make the value zero if the return is null?




pgsql-general by date:

Previous
From: "Zhang Zhb"
Date:
Subject: copyright problem
Next
From: Thomas Swan
Date:
Subject: Re: [ADMIN] Can't connect to PGSQL