null value in queries to default in zero

From: "Dorward Villaruz" <dorwardv(at)ntsp(dot)nec(dot)co(dot)jp>
To: "Postgres General" <pgsql-general(at)postgresql(dot)org>
Subject: null value in queries to default in zero
Date: 2002-11-12 13:49:59
Message-ID: 000b01c28a52$64cbe2b0$043d1cac@speed
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message tony 2002-11-12 14:15:46 test
Previous Message frank_lupo 2002-11-12 13:46:44 psql write in vbs download now