From: Deva Vejay <devavejay@preveho.com>
To: pgsql-sql@postgresql.org
Subject: Max () of an empty table... I need it to return 0 any ideas?
Date: Tue, 22 Jun 1999 14:18:51 -0400
Message-ID: <006801bebcdb$af11ed80$0201a8c0@jupiter.netdepot.com> (raw)
I was looking thru the postgresql message archive searching for a solution to my problem... which you articulated quit well... if you have max(key) of an empty table, the result set is { } which when added to anything gives you { }
do you know how make the result of max(key) of a empty table return 0 we have tried writing our oun c funtion :
int
newmax (int arg,int arg2) {
if (arg2==0)
{
return (arg2);
}
else
{
return(arg);
}
}
we call it :
select newmax(max({key}), Count({key})) which returns us { }
if we call it w/ select newmax(3,0)) returns 0
if we call it w/ select newmax(12,4)) returns 4
it does not work on an empty table :(
please help...
-Deva Vejay
devavejay@preveho.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: devavejay@preveho.com
Subject: Re: Max () of an empty table... I need it to return 0 any ideas?
In-Reply-To: <006801bebcdb$af11ed80$0201a8c0@jupiter.netdepot.com>
References: <006801bebcdb$af11ed80$0201a8c0@jupiter.netdepot.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox