From: Rudi Starcevic <rudi@oasis.net.au>
To: pgsql-sql@postgresql.org
Subject: CASE
Date: Tue, 08 Apr 2003 18:29:07 +1000
Message-ID: <3E928853.7090801@oasis.net.au> (raw)
Hi,
I'm trying to find the maximum date then compare that date to see if I
have any current events to show.
Here is an SQL snippet ( the e.edate field is of type 'date' )
CASE
WHEN COALESCE( MAX(e.edate),'2003-01-01') >= now()::date THEN 'events'
ELSE 'noevents'
END as myevents,
It works fine for those events who do have dates greater or equal to now and
also for those events who have a NULL value.
However there is one event which is in the past '2003-04-01' which is
still coming up as 'events' instead of 'noevents'.
I think there may be something wrong with my CASE SQL clause.
I can't see any problem right now can anyone here see one ?
Thank you kindly
Regards
Rudi.
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: rudi@oasis.net.au
Subject: Re: CASE
In-Reply-To: <3E928853.7090801@oasis.net.au>
* 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